From 3a859a51fb904a57446ccf62fe0a55ea3714a9be Mon Sep 17 00:00:00 2001 From: RockYang Date: Wed, 12 Apr 2023 18:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E6=95=88=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/chat_handler.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/server/chat_handler.go b/server/chat_handler.go index cb3db17..a8184f6 100644 --- a/server/chat_handler.go +++ b/server/chat_handler.go @@ -61,18 +61,18 @@ func (s *Server) ChatHandle(c *gin.Context) { return } logger.Info("Receive a message: ", string(message)) - replyMessage(client, "当前 TOKEN 无效,请使用合法的 TOKEN 登录!", false) - replyMessage(client, "![](images/wx.png)", true) - //ctx, cancel := context.WithCancel(context.Background()) - //s.ReqCancelFunc[sessionId] = cancel - //// 回复消息 - //err = s.sendMessage(ctx, session, chatRole, string(message), client, false) - //if err != nil { - // logger.Error(err) - //} else { - // replyChunkMessage(client, types.WsMessage{Type: types.WsEnd, IsHelloMsg: false}) - // logger.Info("回答完毕: " + string(message)) - //} + //replyMessage(client, "当前 TOKEN 无效,请使用合法的 TOKEN 登录!", false) + //replyMessage(client, "![](images/wx.png)", true) + ctx, cancel := context.WithCancel(context.Background()) + s.ReqCancelFunc[sessionId] = cancel + // 回复消息 + err = s.sendMessage(ctx, session, chatRole, string(message), client, false) + if err != nil { + logger.Error(err) + } else { + replyChunkMessage(client, types.WsMessage{Type: types.WsEnd, IsHelloMsg: false}) + logger.Info("回答完毕: " + string(message)) + } } }()