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
|
||||
}
|
||||
//简单协议:bind:<uid>
|
||||
if len(message) > 5 && string(message[:5]) == "bind:" {
|
||||
uid := string(message[5:])
|
||||
if c.Headers("Sec-Websocket-Protocol") == "bind" && c.Headers("X-Session") != "" {
|
||||
uid := c.Headers("X-Session")
|
||||
_ = h.Gw.BindUid(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)
|
||||
if chatType == constant.ConnStatusClosed {
|
||||
|
|
Loading…
Reference in New Issue