This commit is contained in:
eson 2023-08-16 13:13:45 +08:00
parent 2a532efdcb
commit f3de061423
2 changed files with 16 additions and 2 deletions

View File

@ -54,8 +54,22 @@ func queueHandler(w http.ResponseWriter, r *http.Request) {
continue
}
var wdata []byte
switch data := item.Data.(type) {
case string:
wdata = []byte(data)
case []byte:
wdata = data
default:
wdata, err = json.Marshal(data)
if err != nil {
log.Println(err)
continue
}
}
// 写回消息
err = conn.WriteMessage(websocket.BinaryMessage, []byte(item.Data.(string)))
err = conn.WriteMessage(websocket.BinaryMessage, wdata)
if err != nil {
log.Println(err)
log.Println("重新回队")

View File

@ -37,7 +37,7 @@ func TestWebsocketC(t *testing.T) {
fusenrender.StartNode(svc)
}
var addr = "localhost:4050"
var addr = "api.fusen.3718.cn:4050"
func TestWebsocketCient(t *testing.T) {
// u := url.URL{Scheme: "ws", Host: addr, Path: "/ws/pop/queue"}