コード例 #1
0
        public static MQActionResult <string> Login(string sessionId, SysMemberLoginParam param)
        {
            //if (PublicData.ServerParameter.IsEmpty())
            //{
            //    return MQActionResult<string>.Error(CommonErrors.CenterServerNotStart);
            //}

            var user = SysMemberService.Instance.FindByUserName(param.UserName);

            if (user == null)
            {
                return(MQActionResult <string> .Error($"没找到用户'{param.UserName}'"));
            }

            if (!CryptoUtil.MD5(param.Password).Equals(user.Pwd))
            {
                return(MQActionResult <string> .Error("用户名或密码不正确!"));
            }

            // 检查不允许重复登陆
            if (SessionPool.GetDeskClientSessionIdByUserName(param.UserName) != null)
            {
                return(MQActionResult <string> .Error($"用户'{param.UserName}'正在别处登陆,请先关闭之前的登陆账户"));
            }

            // 为新的Session分配新的BetServer
            //string betServerId = AccountMapping.RandomlyAssignedABetServerId();
            //if (string.IsNullOrEmpty(betServerId))
            //{
            //    return MQActionResult<string>.Error("投注服务资源不足,无法登陆,请联系客服!");
            //}
            //Session betServerSession = SessionPool.GetByClientId(betServerId, ClientTypeEnum.Bet);
            //if (betServerSession == null)
            //{
            //    return MQActionVoidResult.Error("未找到匹配的投注端");
            //}

            // 创建Session
            sessionId = Guid.NewGuid().ToString();
            Session newession = new Session(sessionId, ClientTypeEnum.Client)
            {
                SysmemberId       = user.Id,
                SysmemberUsername = user.Account,
                BetServerId       = "" //betServerId
            };

            SessionPool.SetNew(sessionId, newession);

            // 为BetServerSession设置ClientDeskId
            //betServerSession.ClientDeskId = sessionId;

            SysMemberService.Instance.UpdateLoginTime(user.Id);
            return(MQActionResult <string> .Ok(newession.ClientId));
        }
コード例 #2
0
        /// <summary>
        /// 某个端建立连接, 并由中心服务器返回分配的SessionId
        /// </summary>
        /// <param name="sessionId">空字符串</param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static MQActionResult <string> Connect(string sessionId, ValueTypeParam <ClientTypeEnum> param)
        {
            if (param.Value == ClientTypeEnum.Client)
            {
                return(MQActionResult <string> .Error("控盘端只能在登陆成功逻辑中创建Session."));
            }

            sessionId = Guid.NewGuid().ToString();
            Session session = new Session(sessionId, param.Value);

            session.platform = param.Platform;

            SessionPool.SetNew(sessionId, session);

            // 投注端建立链接,初始化可投注缓存数据
            if (param.Value == ClientTypeEnum.Bet)
            {
                AccountMapping.AddAvailableBetServer(sessionId);
            }

            return(MQActionResult <string> .Ok(sessionId));
        }