Files
ai/test_ws.sh
2023-07-15 15:18:58 +08:00

28 lines
590 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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"