public int HandlePacket(BaseClient bcclient, PacketIn packet) { LobbyClient client = bcclient as LobbyClient; packet.Skip(25); string Username = packet.GetParsedString(); Log.Notice("ASK_LOGIN", "Account: " + Username); try { client.Account = Databases.AccountTable.SingleOrDefault(a => a.Username == Username); if (client.Account.Verifier.Length <= 2 || client.Account.Salt.Length <= 2) { Register(client); } client.Salt = new FrameWork.NetWork.Crypto.BigInteger(client.Account.Salt, 16).ToByteArrayUnsigned(); client.Verifier = new FrameWork.NetWork.Crypto.BigInteger(client.Account.Verifier, 16); Log.Succes("ASK_LOGIN", "Account exists: " + client.Account.Username); LOGIN_SALT.Send(client); } catch (ArgumentNullException) { Log.Error("ASK_LOGIN", "Database is busy"); LOGIN_FAILED.Send(client, (int)ResponseCodes.RC_DATABASE_BUSY); client.Disconnect(); } catch (Exception e) { Log.Error("ASK_LOGIN", "Account is not found"); Log.Debug("ASK_LOGIN", e.ToString()); LOGIN_FAILED.Send(client, (int)ResponseCodes.RC_LOGIN_INVALID_ACCOUNT); client.Disconnect(); } return(0); }
public int HandlePacket(BaseClient client, PacketIn packet) { LobbyClient cclient = (LobbyClient)client; PacketOut Out = new PacketOut((uint)Opcodes.ANS_CHARACTER_CREATE); byte freeSlot = GetFreeSlot(cclient); if (freeSlot == 0) { Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED); } else { cclient.Pending.Slot = freeSlot; cclient.Pending.Faction = packet.GetUint8(); cclient.Pending.Gender = packet.GetUint8(); cclient.Pending.Version = (byte)packet.GetUint32Reversed(); packet.GetUint32Reversed(); byte[] Custom = new byte[packet.Length - packet.Position]; packet.Read(Custom, 0, Custom.Length); cclient.Pending.Appearance = BitConverter.ToString(Custom); Databases.CharacterTable.Add(cclient.Pending); Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS); Out.WriteInt32Reverse(cclient.Pending.Slot); } cclient.Send(Out); System.Threading.Thread.Sleep(500); cclient.Pending = default(CharacterEntry); System.Threading.Thread.Sleep(500); cclient.Disconnect(); return(0); }
public int HandlePacket(BaseClient client, PacketIn packet) { LobbyClient cclient = client as LobbyClient; byte[] clientModulus = new byte[64]; for (int i = 0; i < 64; ++i) { clientModulus[i] = packet.GetUint8(); } cclient.clientModulus = new FrameWork.NetWork.Crypto.BigInteger(1, clientModulus); ushort unk = packet.GetUint16(); byte[] Proof = new byte[20]; for (int i = 0; i < 20; ++i) { Proof[i] = packet.GetUint8(); } cclient.Proof = Proof; if (IsBanned(cclient)) { LOGIN_FAILED.Send(cclient, (int)ResponseCodes.RC_LOGIN_ACCOUNT_BLOCKED); cclient.Disconnect(); } else { if (IsValid(cclient)) { LOGIN_SUCCES.Send(cclient); cclient.ECrypt = new Encryption(cclient.SessionId); CHARACTER_LIST.Send(cclient); } else { LOGIN_FAILED.Send(cclient, (int)ResponseCodes.RC_LOGIN_INVALID_ACCOUNT); cclient.Disconnect(); } } return(0); }
public void Disconnect() { State = ClientState.Disconnected; LobbyClient?.Disconnect(); WorldClient?.Disconnect(); }
public void Disconnect() { _state = ClientState.Disconnected; _lobbyClient?.Disconnect(); _worldClient?.Disconnect(); }