protected void HandleUserOffline(GSPacketIn packet) { int num = packet.ReadInt(); for (int i = 0; i < num; i++) { int num2 = packet.ReadInt(); int consortiaID = packet.ReadInt(); if (LoginMgr.ContainsUser(num2)) { this.SendAllowUserLogin(num2); } WorldMgr.OnPlayerOffline(num2, consortiaID); } }
protected void HandleUserOffline(GSPacketIn packet) { int count = packet.ReadInt(); for (int i = 0; i < count; i++) { int playerid = packet.ReadInt(); int consortiaID = packet.ReadInt(); if (LoginMgr.ContainsUser(playerid)) { this.SendAllowUserLogin(playerid); } WorldMgr.OnPlayerOffline(playerid, consortiaID); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { try { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.LOGIN); pkg.ClientID = packet.ClientID; if (client.Player == null) { int version = packet.ReadInt(); int clientType = packet.ReadInt(); byte[] src = packet.ReadBytes(); //解密 try { src = WorldMgr.RsaCryptor.Decrypt(src, false); } catch (ExecutionEngineException e) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError")); client.Disconnect(); GameServer.log.Error("ExecutionEngineException", e); return(0); } catch (Exception ex) { //防止攻击,如果解密出错,直接断开连接 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError")); client.Disconnect(); GameServer.log.Error("RsaCryptor", ex); return(0); } //DateTime date = new DateTime(src[0] * 256 + src[1], src[2], src[3], src[4], src[5], src[6]); int fms_key = (src[7] << 8) + src[8]; client.SetFsm(fms_key, version); //string edition = GameServer.Instance.Configuration.Edition; string edition = GameServer.Edition; //if (version.ToString() != edition && edition != "0") //{ // client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError")); // //client.Out.SendEditionError(LanguageMgr.GetTranslation("UserLoginHandler.EditionError")); // client.Disconnect(); // return 0; //} string[] temp = Encoding.UTF8.GetString(src, 9, src.Length - 9).Split(','); if (temp.Length == 2) { string user = temp[0]; string pass = temp[1]; //TimeSpan span = date - DateTime.UtcNow; //if (Math.Abs(span.TotalMinutes) < 5) //{ if (!LoginMgr.ContainsUser(user)) { bool isFirst = false; BaseInterface inter = BaseInterface.CreateInterface(); PlayerInfo cha = inter.LoginGame(user, pass, ref isFirst); if (cha != null && cha.ID != 0) { if (cha.ID == -2) { //帐号被禁用 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid")); client.Disconnect(); return(0); } if (!isFirst) { client.Player = new GamePlayer(cha.ID, user, client, cha); LoginMgr.Add(cha.ID, client); client.Server.LoginServer.SendAllowUserLogin(cha.ID); client.Out.SendLoginSuccess2(); client.Version = version; } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register")); client.Disconnect(); } } else { //client.Out.SendLoginFailed("用户名密码错误"); client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime")); client.Disconnect(); } } else { //避免攻击,有另外的客户端在登陆,则断掉次客户端。 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError")); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError")); //验证格式错误,端口连接 client.Disconnect(); } } } catch (Exception ex) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError")); client.Disconnect(); GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError"), ex); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { try { if (client.Player == null) { int version = packet.ReadInt(); packet.ReadInt(); byte[] array = new byte[8]; byte[] array2 = packet.ReadBytes(); try { array2 = WorldMgr.RsaCryptor.Decrypt(array2, false); } catch (ExecutionEngineException exception) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); client.Disconnect(); GameServer.log.Error("ExecutionEngineException", exception); int result = 0; return(result); } catch (Exception exception2) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); client.Disconnect(); GameServer.log.Error("RsaCryptor", exception2); int result = 0; return(result); } string arg_B1_0 = GameServer.Edition; for (int i = 0; i < 8; i++) { array[i] = array2[i + 7]; } client.setKey(array); string[] array3 = Encoding.UTF8.GetString(array2, 15, array2.Length - 15).Split(new char[] { ',' }); if (array3.Length == 2) { string text = array3[0]; string pass = array3[1]; if (!LoginMgr.ContainsUser(text)) { bool flag = false; BaseInterface baseInterface = BaseInterface.CreateInterface(); PlayerInfo playerInfo = baseInterface.LoginGame(text, pass, ref flag); if (playerInfo != null && playerInfo.ID != 0) { if (playerInfo.ID == -2) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid", new object[0])); client.Disconnect(); int result = 0; return(result); } if (!flag) { client.Player = new GamePlayer(playerInfo.ID, text, client, playerInfo); LoginMgr.Add(playerInfo.ID, client); client.Server.LoginServer.SendAllowUserLogin(playerInfo.ID); client.Version = version; } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError", new object[0])); client.Disconnect(); } } } catch (Exception exception3) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0])); client.Disconnect(); GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0]), exception3); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int result; try { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); if (client.Player == null) { int version = packet.ReadInt(); int clientType = packet.ReadInt(); byte[] src = packet.ReadBytes(); try { src = WorldMgr.RsaCryptor.Decrypt(src, false); } //catch (ExecutionEngineException e) //{ // client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); /// client.Disconnect(); // GameServer.log.Error("ExecutionEngineException", e); // result = 0; // return result; //} catch (Exception ex) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); client.Disconnect(); GameServer.log.Error("RsaCryptor", ex); result = 0; return(result); } int fms_key = ((int)src[7] << 8) + (int)src[8]; client.SetFsm(fms_key, version); string edition = GameServer.Edition; if (version < int.Parse(GameServer.Edition) || version >= int.Parse(GameServer.Edition) + 1000) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError", new object[0])); GameServer.log.Error("Edition Error"); client.Disconnect(); result = 0; return(result); } string[] temp = Encoding.UTF8.GetString(src, 9, src.Length - 9).Split(new char[] { ',' }); if (temp.Length == 2) { string user = temp[0]; string pass = temp[1]; if (!LoginMgr.ContainsUser(user)) { bool isFirst = false; LSJInterface inter = LSJInterface.CreateInterface(); PlayerInfo cha = null; int userID = 0; if (OpenAPIs.ValidateLoginAndGetID(user, pass, ref userID, ref isFirst)) { cha = new PlayerInfo { ID = userID, UserName = user }; } if (cha != null && cha.ID != 0) { if (cha.ID == -2) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid", new object[0])); client.Disconnect(); result = 0; return(result); } if (!isFirst) { client.Player = new GamePlayer(cha.ID, user, client, cha, this.GetClientType(clientType)); LoginMgr.Add(cha.ID, client); client.Server.LoginServer.SendAllowUserLogin(cha.ID); client.Version = version; } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError", new object[0])); client.Disconnect(); } } } catch (Exception ex) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0])); client.Disconnect(); GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0]), ex); } result = 1; return(result); }