From ed5b215bbbcb23e817ea170930cbb6bef52e17e9 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Sun, 21 Aug 2022 16:05:58 +0800 Subject: [PATCH] pc terminal can login at same time --- internal/msg_gateway/gate/ws_server.go | 10 ++++++++++ pkg/common/constant/constant.go | 2 ++ 2 files changed, 12 insertions(+) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index b2ea4c6eb..fd2190efb 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -147,6 +147,11 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int, defer rwLock.Unlock() log.NewInfo(operationID, utils.GetSelfFuncName(), " rpc args: ", uid, platformID, token) switch config.Config.MultiLoginPolicy { + case constant.PCAndOther: + if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC { + return + } + fallthrough case constant.AllLoginButSameTermKick: if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn] if oldConn, ok := oldConnMap[platformID]; ok { @@ -197,6 +202,11 @@ func (ws *WServer) MultiTerminalLoginCheckerWithLock(uid string, platformID int, func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn *UserConn, token string, operationID string) { switch config.Config.MultiLoginPolicy { + case constant.PCAndOther: + if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == constant.TerminalPC { + return + } + fallthrough case constant.AllLoginButSameTermKick: if oldConnMap, ok := ws.wsUserToConn[uid]; ok { // user->map[platform->conn] if oldConn, ok := oldConnMap[platformID]; ok { diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 846b07a14..c8f9986b4 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -140,6 +140,8 @@ const ( WebAndOther = 3 //The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at the same time PcMobileAndWeb = 4 + //The PC terminal can be online at the same time,but other terminal only one of the endpoints can login + PCAndOther = 5 OnlineStatus = "online" OfflineStatus = "offline"