结构修改
This commit is contained in:
parent
39b5dd2e35
commit
9699bbacbc
|
@ -142,20 +142,6 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
|
|||
}()
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
_ = entitys.MsgSend(c, entitys.Response{
|
||||
|
||||
Content: err.Error(),
|
||||
Type: entitys.ResponseErr,
|
||||
})
|
||||
}
|
||||
_ = entitys.MsgSend(c, entitys.Response{
|
||||
|
||||
Content: "",
|
||||
Type: entitys.ResponseEnd,
|
||||
})
|
||||
|
||||
//r.channelPool.Put(ch)
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ func (h *ChatService) Chat(c *websocket.Conn) {
|
|||
h.Gw.AddClient(client)
|
||||
log.Println("client connected:", clientID)
|
||||
log.Println("客户端已连接")
|
||||
|
||||
// 循环读取客户端消息
|
||||
for {
|
||||
messageType, message, err := c.ReadMessage()
|
||||
|
@ -108,8 +109,11 @@ func (h *ChatService) Chat(c *websocket.Conn) {
|
|||
Content: err.Error(),
|
||||
Type: entitys.ResponseErr,
|
||||
})
|
||||
continue
|
||||
}
|
||||
_ = entitys.MsgSend(c, entitys.Response{
|
||||
Content: "",
|
||||
Type: entitys.ResponseEnd,
|
||||
})
|
||||
}
|
||||
h.Gw.RemoveClient(clientID)
|
||||
_ = c.Close()
|
||||
|
|
Loading…
Reference in New Issue