Example #1
0
        public CharactersClient(string address, int port, Player player, Character character) : base(address, port, player, character)
        {
            FirstMessage message    = new FirstMessage(ClientType.CharactersClient, Player, Character);
            string       serialized = JsonConvert.SerializeObject(message);

            byte[] data = Encoding.Unicode.GetBytes(serialized);
            Stream.Write(data, 0, data.Length);
            IsConnected      = true;
            CharactersInRoom = new List <Character>();
        }
Example #2
0
 public ChatClient(string address, int port, Player player, Character character) : base(address, port, player, character)
 {
     try
     {
         FirstMessage message    = new FirstMessage(ClientType.ChatClient, Player, Character);
         string       serialized = JsonConvert.SerializeObject(message);
         byte[]       data       = Encoding.Unicode.GetBytes(serialized);
         Stream.Write(data, 0, data.Length);
         IsConnected = true;
         Messages    = new List <ChatMessage>();
     }
     catch (Exception)
     {
         IsConnected = false;
         MessageBox.Show("Хост не найден");
     }
 }
Example #3
0
        public void Process()
        {
            FirstMessage firstMessage = GetFirstMessage();

            Player    = firstMessage.Player;
            Character = firstMessage.Character;
            Type      = firstMessage.Type;
            if (Type == ClientType.ChatClient)
            {
                ChatProcess();
            }
            else if (Type == ClientType.StateClient)
            {
                StateProcess();
            }
            else if (Type == ClientType.CharactersClient)
            {
                CharactersProcess();
            }
            else if (Type == ClientType.FileClient)
            {
                FileProcess();
            }
        }