Merge remote-tracking branch 'origin/feature/fiber' into feature/fiber
This commit is contained in:
commit
0ce09611de
|
@ -81,17 +81,10 @@ func (h *ChatService) Chat(c *websocket.Conn) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
//简单协议:bind:<uid>
|
//简单协议:bind:<uid>
|
||||||
if len(message) > 5 && string(message[:5]) == "bind:" {
|
if c.Headers("Sec-Websocket-Protocol") == "bind" && c.Headers("X-Session") != "" {
|
||||||
uid := string(message[5:])
|
uid := c.Headers("X-Session")
|
||||||
_ = h.Gw.BindUid(clientID, uid)
|
_ = h.Gw.BindUid(clientID, uid)
|
||||||
log.Printf("bind %s -> uid:%s\n", clientID, uid)
|
log.Printf("bind %s -> uid:%s\n", clientID, uid)
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 回显
|
|
||||||
err = h.Gw.SendToClient(clientID, []byte("echo: "+string(message)))
|
|
||||||
if err != nil {
|
|
||||||
h.ChatFail(c, "send to client failed")
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
msg, chatType := h.handleMessageToString(c, messageType, message)
|
msg, chatType := h.handleMessageToString(c, messageType, message)
|
||||||
if chatType == constant.ConnStatusClosed {
|
if chatType == constant.ConnStatusClosed {
|
||||||
|
|
Loading…
Reference in New Issue