This commit is contained in:
苏尹岚
2020-12-03 17:50:48 +08:00
parent 97b59580ab
commit 83190dc848

View File

@@ -104,8 +104,10 @@ func (c *EventController) TestWebsocket() {
//接收客户端的消息
err := ws.ReadJSON(&s)
if err != nil {
fmt.Println("11111111111111111111111111111111111111111111111111111111111111111111")
var m *Message
if err2 := ws.ReadJSON(&m); err2 == nil {
fmt.Println("22222222222222222222222222222222222222222222222222222", utils.Format4Output(m, false))
m.UserID = userID
heartbit <- m
} else {
@@ -113,6 +115,7 @@ func (c *EventController) TestWebsocket() {
for k, _ := range clients {
delete(clients[k], userID)
}
delete(heartClients, userID)
break //结束循环
}
} else {
@@ -174,6 +177,7 @@ func handleMessages() {
}
}
case h := <-heartbit:
fmt.Println("33333333333333333333333333333333333333333333333333", utils.Format4Output(h, false))
globals.SugarLogger.Debugf("h %v", utils.Format4Output(h, false))
if err := heartClients[h.UserID].WriteJSON(&Message{
Data: "pang",