变化事件监听
This commit is contained in:
27
test_ws.sh
Executable file
27
test_ws.sh
Executable 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"
|
Reference in New Issue
Block a user