// solicita o nome do usuário private string GetUserName() { Console.WriteLine("Please enter your username."); string user = UserConsole.GetInput(); return(user); }
// monitora as mensagens recebidas public void Receive() { while (connected == true) { try { byte[] receivedMessages = new byte[88]; stream.Read(receivedMessages, 0, receivedMessages.Length); UserConsole.DisplayMessage(Encoding.ASCII.GetString(receivedMessages)); } catch (Exception e) { Console.WriteLine(e); } } }
// monitora as mensagens enviadas public void Send() { while (connected == true) { try { string messageString = UserConsole.GetInput(); byte[] message = Encoding.ASCII.GetBytes(messageString); stream.Write(message, 0, message.Count()); } catch (Exception e) { Console.WriteLine(e); } } }