变化事件监听

This commit is contained in:
2023-07-15 15:18:58 +08:00
parent 5add1c6e53
commit 64707229a5
3 changed files with 203 additions and 0 deletions

27
test_ws.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
go run main.go -procname go_test &
sleep 6
# 退出服務的函數
function exit_service() { pkill -f go_test && echo "退出服務: $1" && exit 1; }
# 安装websocketd
# 参考https://github.com/joewalnes/websocketd/wiki/Installation
# 下载地址https://github.com/joewalnes/websocketd/releases
# 启动 WebSocket 服务
# websocketd --port=8080 echo
# 连接 WebSocket 客户端
wscat -c ws://localhost:8080/api/ws
## 发送消息
#echo "Hello, WebSocket!" | nc localhost 8080
#
## 接收消息
#nc -l localhost 8080
# 退出
sleep 20
exit_service "test_ws.sh"