edu.pdx.cs399J.net
Class ChatSpeaker

java.lang.Object
  extended by edu.pdx.cs399J.net.ChatSpeaker
All Implemented Interfaces:
Runnable

public class ChatSpeaker
extends Object
implements Runnable

A ChatSpeaker runs in the background and sends ChatMessages over a Socket.


Constructor Summary
ChatSpeaker()
          Creates a new ChatSpeaker
 
Method Summary
 void run()
          A ChatSpeaker uses wait/notify on its incoming list to know when to send a message.
 void sendMessage(ChatMessage message)
          Queues a message to be sent.
 void setSocket(Socket socket)
          Sets the socket to which this ChatSpeaker sends messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatSpeaker

public ChatSpeaker()
Creates a new ChatSpeaker

Method Detail

setSocket

public void setSocket(Socket socket)
Sets the socket to which this ChatSpeaker sends messages.


run

public void run()
A ChatSpeaker uses wait/notify on its incoming list to know when to send a message. For the sake of symmetry, we interrupt it to tell it to stop.

Specified by:
run in interface Runnable

sendMessage

public void sendMessage(ChatMessage message)
Queues a message to be sent. This method will be called by a thread other than the one running run().



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