Class ChatListener

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

public class ChatListener extends Object implements Runnable
A ChatListener runs in the background and listens for messages on a socket on localhost.
  • Constructor Details

    • ChatListener

      public ChatListener()
      Creates a new ChatListener
  • Method Details

    • setSocket

      public void setSocket(Socket socket)
      Sets the socket on which this ChatListener listens
    • run

      public void run()
      Sit in a loop and wait for messages to come in. Unfortunately, calling the constructor of ObjectInputStream blocks. So, we have to encode a "STOP" command in the final message. Awful.
      Specified by:
      run in interface Runnable
    • getMessages

      public List getMessages()
      Returns all incoming messages. This method will be called by a thread other than the one running run().