void NotifyLobbyUserLoginResult(string password, long userId, Msg_C2I_UserLogin cInfo, IIncommingMessage reader) { if (cInfo.Password != password) { reader.Respond(EMsgSC.I2C_LoginResult, new Msg_I2C_LoginResult() { LoginResult = (byte)ELoginResult.PasswordMissMatch }); } else { var loginHash = "LSHash" + Time.timeSinceLevelLoad; _netClientLI.SendMessage(EMsgLS.I2L_UserLogin, new Msg_I2L_UserLogin() { Account = cInfo.Account, GameType = cInfo.GameType, UserId = userId, LoginHash = loginHash }, (sta, res) => { reader.Respond(EMsgSC.I2C_LoginResult, new Msg_I2C_LoginResult() { LoginResult = (byte)ELoginResult.Succ, UserId = userId, LoginHash = loginHash, LobbyEnd = new IPEndInfo() { Ip = lobbyInfo.Ip, Port = lobbyInfo.Port } }); }); } }
void CreateUser(Msg_C2I_UserLogin cInfo, IIncommingMessage reader){ _netClientDS.SendMessage(EMsgDS.S2D_ReqCreateUser, new Msg_ReqAccountData() { account = cInfo.Account, password = cInfo.Password }, (status, response) => { var msg = response.Parse<Msg_RepCreateResult>(); NotifyLobbyUserLoginResult(cInfo.Password, msg.userId, cInfo, reader); }); }
void ReqUserInfo(Msg_C2I_UserLogin cInfo, IIncommingMessage reader){ var account = cInfo.Account; var password = cInfo.Password; _netClientDS?.SendMessage(EMsgDS.S2D_ReqUserInfo, new Msg_ReqAccountData() { account = account, password = password }, (status, response) => { var msg = response.Parse<Msg_RepAccountData>(); if (msg.accountData == null) { CreateUser(cInfo, reader); } else { //密码不正确 NotifyLobbyUserLoginResult(msg.accountData.Password, msg.accountData.UserId, cInfo, reader); } }); }