From c2782a4bb690cd2e3e19d837b7a8e1a07807255b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Sat, 11 Jun 2022 09:19:06 +0800 Subject: [PATCH] SetWriteTimeoutWriteMsg --- internal/msg_gateway/gate/ws_server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index b7c297aa3..7977828e8 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -100,6 +100,13 @@ func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error { return conn.WriteMessage(a, msg) } +func (ws *WServer) SetWriteTimeoutWriteMsg(conn *UserConn, a int, msg []byte, timeout int) error { + conn.w.Lock() + defer conn.w.Unlock() + conn.SetWriteDeadline(time.Now().Add(time.Duration(timeout) * time.Second)) + return conn.WriteMessage(a, msg) +} + func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int32, newConn *UserConn, token string, operationID string) { switch config.Config.MultiLoginPolicy { case constant.AllLoginButSameTermKick: