Class ChatCommunicator

java.lang.Object
edu.pdx.cs410J.net.ChatCommunicator
All Implemented Interfaces:
Runnable

public class ChatCommunicator extends Object implements Runnable
A ChatCommunicator obtains a Socket and then creates a ChatSpeaker and a ChatListener that run in their own threads.
  • Constructor Details

    • ChatCommunicator

      public ChatCommunicator(int port)
      Creates a new ChatCommunicator on a given port.
  • Method Details

    • startup

      public void startup()
      Starts up this ChatCommunicator.
    • run

      public void run()
      Make the connection to the socket. If it cannot open a Socket, is starts a SocketServer and waits for a connection. Then, start the speaker and listener.
      Specified by:
      run in interface Runnable
    • sendMessage

      public void sendMessage(ChatMessage message)
      Delegates to the ChatSpeaker
    • getMessages

      public List getMessages()
      Gets messages from the ChatListener