public bool DisconnectClient(AuthClient newClient) { bool succes = false; AuthClient client = AuthServer.Instance.GetClients().Find(x => x.Account != null && x.Account.Id == newClient.Account.Id); if (client != null) { client.Disconnect(); succes = true; } else { if (newClient.Account.LastSelectedServerId != 0) { TransitionClient server = TransitionServer.Instance.GetServerClient(newClient.Account.LastSelectedServerId); var serverData = ServerRecord.GetWorldServer(newClient.Account.LastSelectedServerId); if (server != null && server.IsConnected && serverData != null && serverData.Status != ServerStatusEnum.STARTING) // Online { MessagePool.SendRequest <DisconnectClientResultMessage>(server, new DisconnectClientRequestMessage { AccountId = newClient.Account.Id, }, delegate(DisconnectClientResultMessage message) { succes = message.IsSucces; }, delegate() { this.OnTransitionFailed(newClient); }); } else { succes = false; } } } return(succes); }
public static void HandleCharacterCreation(CharacterCreationRequestMessage message, WorldClient client) { if (!WorldServer.Instance.IsStatus(ServerStatusEnum.ONLINE)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NO_REASON)); return; } if (!client.InGame) { if (client.Characters.Count() == client.Account.CharacterSlots) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_TOO_MANY_CHARACTERS)); return; } if (CharacterRecord.NameExist(message.name)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NAME_ALREADY_EXISTS)); return; } if (client.Account.Role < ServerRoleEnum.Animator) { foreach (var value in message.name) { if (UnauthorizedNameContent.Contains(value)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_INVALID_NAME)); return; } } } if (message.name.Split(null).Count() > 1) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_INVALID_NAME)); return; } long nextId = CharacterRecord.Characters.DynamicPop(x => x.Id); MessagePool.SendRequest <OnCharacterCreationResultMessage>(TransitionServerManager.Instance.AuthServer, new OnCharacterCreationMessage { AccountId = client.Account.Id, CharacterId = nextId, }, delegate(OnCharacterCreationResultMessage result) { CreateCharacter(message, client, result.Succes, nextId); }); } }
public static void HandleAuthentificationTicketMessage(AuthenticationTicketMessage message, WorldClient client) { lock (m_locker) { var reader = new BigEndianReader(Encoding.ASCII.GetBytes(message.ticket)); var count = reader.ReadByte(); var ticket = reader.ReadUTFBytes(count); MessagePool.SendRequest <AccountMessage>(TransitionServerManager.Instance.AuthServer, new AccountRequestMessage { Ticket = ticket }, delegate(AccountMessage msg) { OnAccountReceived(client, msg); }, delegate() { OnAccountReceptionError(client); }); } }
public static void HandleCharacterDeletionRequest(CharacterDeletionRequestMessage message, WorldClient client) { if (!WorldServer.Instance.IsStatus(ServerStatusEnum.ONLINE)) { client.Send(new CharacterDeletionErrorMessage((sbyte)CharacterDeletionErrorEnum.DEL_ERR_NO_REASON)); return; } if (!client.InGame) { MessagePool.SendRequest <OnCharacterDeletionResultMessage>(TransitionServerManager.Instance.AuthServer, new OnCharacterDeletionMessage { CharacterId = (long)message.characterId, }, delegate(OnCharacterDeletionResultMessage msg) { ProcessDeletion(msg.Succes, client, (long)message.characterId); }); } }
public bool Ban() { bool result = false; if (this.Account != null) { MessagePool.SendRequest <BanConfirmMessage>(TransitionServerManager.Instance.AuthServer, new BanRequestMessage { AccountId = this.Account.Id }, delegate { result = true; this.Disconnect(); }, delegate { }); } return(result); }