/// <summary> /// 登陆 /// </summary> private void OnClientLogin(PacketBase packet) { gs2ws.ClientLogin msg = packet as gs2ws.ClientLogin; string account_name = msg.name; string account_psw = msg.psw; ClientUID client_uid = msg.client_uid; //查询是否在缓存 AccountData account_data = new AccountData(); if (AccountCacheManager.Instance.GetAccountData(account_name, ref account_data)) { CheckAccountLogin(client_uid, account_name, account_psw, account_data); } else { SQLLoginHandle.QueryAccountData(account_name, (data) => { AccountCacheManager.Instance.AddAccountData(account_name, data); CheckAccountLogin(client_uid, account_name, account_psw, data); } ); } }
/// <summary> /// 登陆 /// </summary> private void OnClientLogin(ClientSession session, PacketBase packet) { c2gs.ClientLogin msg = packet as c2gs.ClientLogin; if (string.IsNullOrEmpty(msg.name) || string.IsNullOrEmpty(msg.psw)) { Log.Debug("数据错误 name:" + msg.name); return; } //只有创建或登录错误,才能进一步验证 if (session.session_status != eSessionStatus.CREATED && session.session_status != eSessionStatus.LOGIN_FAILED) { Log.Debug("错误的seesion状态:" + session.session_status); return; } //标记状态,正在验证中,防止重复验证 session.session_status = eSessionStatus.LOGIN_DOING; //发给ws请求验证 gs2ws.ClientLogin ws_msg = PacketPools.Get(gs2ws.msg.CLIENT_LOGIN) as gs2ws.ClientLogin; ws_msg.client_uid = session.client_uid; ws_msg.name = msg.name; ws_msg.psw = msg.psw; ServerNetManager.Instance.Send2WS(ws_msg); }