edu.pdx.cs399J.net
Class ChatListener

java.lang.Object
  extended by edu.pdx.cs399J.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 Summary
ChatListener()
          Creates a new ChatListener
 
Method Summary
 List getMessages()
          Returns all incoming messages.
 void run()
          Sit in a loop and wait for messages to come in.
 void setSocket(Socket socket)
          Sets the socket on which this ChatListener listens
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatListener

public ChatListener()
Creates a new ChatListener

Method Detail

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().



Copyright © 2000-2009 Portland State University. All Rights Reserved.