fix
This commit is contained in:
parent
2a532efdcb
commit
f3de061423
16
websocket.go
16
websocket.go
|
@ -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("重新回队")
|
||||
|
|
|
@ -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"}
|
||||
|
|
Loading…
Reference in New Issue
Block a user