/// <summary> /// Returns packet to sender containing the server's announcement, name and the sender's character information. /// </summary> private void ProcessCharacterSelectionRequest(RequestPacket packet) { List<PlayerCharacter> characterList = new List<PlayerCharacter>(); if (Model.ConnectionUsernamesDictionary.ContainsKey(packet.SenderConnection)) { string username = Model.ConnectionUsernamesDictionary[packet.SenderConnection]; using (PlayerCharacterFileAccess repo = new PlayerCharacterFileAccess()) { characterList = repo.GetCharactersByUsername(username); } CharacterSelectionPacket responsePacket = new CharacterSelectionPacket { ServerAnnouncement = Model.ServerAnnouncement, ServerName = Model.ServerName, CharacterList = characterList, CanDeleteCharacters = Model.IsCharacterDeletionEnabled }; Agent.SendPacket(responsePacket, packet.SenderConnection, NetDeliveryMethod.ReliableUnordered); } }
/// <summary> /// Processes a packet containing data related to the character selection screen. /// </summary> /// <param name="packet"></param> private void ProcessCharacterSelectionPacket(CharacterSelectionPacket packet) { ViewModel.CanDeleteCharacters = packet.CanDeleteCharacters; ViewModel.Characters = packet.CharacterList == null ? new List<PlayerCharacter>() : packet.CharacterList; ViewModel.ServerName = packet.ServerName; ViewModel.Announcement = packet.ServerAnnouncement; // Generate portraits for each character for (int index = 0; index < ViewModel.Characters.Count; index++) { string base64Portrait = ViewModel.Characters[index].Portrait.ToBase64String(); ViewModel.CharacterPortraits.Insert(index, base64Portrait); } ViewModel.ActiveCharacterIndex = 0; AsyncJavascriptCallback("RequestServerInformation_Callback"); }