protected virtual void RealmSocket_OnCharacterLogonResponse(CharacterLogonResponse Packet) { RealmCharacterActionResult result = Packet.Result; if (result == RealmCharacterActionResult.Success) { ChannelListRequest bnetPacket = new ChannelListRequest(); this.Chat.SendPacket(bnetPacket); EnterChatRequest bnetPacket2 = new EnterChatRequest(this.Hero.Name); this.Chat.SendPacket(bnetPacket2); JoinChannel bnetPacket3 = new JoinChannel("Diablo II", true); this.Chat.SendPacket(bnetPacket3); } }
private void EnterChatHandler(string requestInJson) { EnterChatRequest request = JsonSerializer.Deserialize <EnterChatRequest>(requestInJson); var response = new EnterChatResponse { RequestId = request.Id }; try { User storedUser = server.UserRepository.GetByName(request.Sender); IChat chat = server.ChatRepository.GetChat(request.ChatName); if (chat == null) { throw new ChatNotFoundException(request.ChatName); } if (storedUser.State != UserState.Authorized) { throw new NotEnoughRightsException(request.Sender, storedUser.State, request.Action); } chat.AddUser(storedUser); storedUser.CurrentChat = chat; storedUser.State = UserState.InChat; response.Key = chat.Key; response.Code = StatusCode.Ok; } catch (NedoGramException customException) { response.Message = customException.Message; response.Code = StatusCode.ClientError; } catch (Exception) { response.Message = "Internal error"; response.Code = StatusCode.ServerError; } finally { SendMessageAesEncrypted(response, ClientAesKey); } }
private void EnterChatRequestHandler() { Console.WriteLine(Environment.NewLine + "Write a chat name:"); chatName = Console.ReadLine(); var request = new EnterChatRequest { ChatName = chatName, Sender = UserName }; responseHandlers.Add(request.Id, EnterChatResponseHandler); SendMessageAesEncrypted(request, serverKey); while (responseHandlers.ContainsKey(request.Id)) { } }