swpchat.client
Class MessageReceiver

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--swpchat.client.MessageReceiver
All Implemented Interfaces:
ChatTokens, java.lang.Runnable, SenderReceiverTokens

public class MessageReceiver
extends java.lang.Thread
implements SenderReceiverTokens

Receives the messages sent by a server and puts them out to a TextArea.

Since:
1.12.1999
Author:
David Kensche, Dirk Hesse

Field Summary
private  boolean boolDisconnect
           
private  ClientControls clientControls
           
(package private)  java.lang.String CLS
           
private  Earmuffs muffVec
           
private  java.util.HashMap replyWaiterHash
           
private  java.net.Socket socket
           
(package private) static int time
           
private  Waiter tmpWaiter
           
private  ChatStreamTokenizer tokenizer
           
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ
 
Fields inherited from interface swpchat.protocol.SenderReceiverTokens
STR_JOIN, STR_JOINPASSWD, STR_LEAVE, STR_OFF, STR_ON, STR_PLAY, STR_PLAY_BEGIN, STR_PLAY_RE_BEGIN, STR_RECEIVE, STR_RECEIVE_BEGIN, STR_RECEIVE_USERINFO, STR_REQUEST_USERINFO, STR_SEND, STR_SEND_BEGIN, STR_SEND_RE_BEGIN, STR_SETTOPIC, STR_SETTOPIC_BEGIN, STR_SHIP, STR_SHIP_BEGIN, STR_TOPICCHANGED, STR_WHISPER, STR_WHISPRECEIVE
 
Fields inherited from interface swpchat.protocol.ChatTokens
CHAR_ARG_SEP, CHAR_MSG_END, CHAR_MSG_EOL, CHAR_QUOTE, CHAR_STRING_DELIMITER, STR_ARG_SEP, STR_AUTHORIZE, STR_MSG_END, STR_MSG_EOL, STR_NEG_ARG, STR_NEGATIVE, STR_POS_ARG, STR_POSITIVE, STR_QUOTE, STR_REPLY, STR_STRING_DELIMITER, STR_WAIT
 
Constructor Summary
MessageReceiver(ClientControls clientControls, ChatStreamTokenizer tokenizer, java.net.Socket socket)
          Constructor of the class MessageReceiver.
 
Method Summary
 Waiter getReplyWaiter(java.lang.String msg)
          returns a waiter thread which will wait for the event specified in msg, see Waiter for details.
 int getTimeout()
          return the Timeout
 void handleNormalRequests(java.util.Vector tokenlist)
          handles all Requests
private  java.util.Vector readCommand(ChatStreamTokenizer tokenizer)
          Fetch one command from the input.
 void run()
          Overrides the method run() in Thread.
 void setDisconnect()
          Give the MessageReceiver the signal to stop receiving.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLS

final java.lang.String CLS

clientControls

private ClientControls clientControls

tokenizer

private ChatStreamTokenizer tokenizer

boolDisconnect

private boolean boolDisconnect

replyWaiterHash

private java.util.HashMap replyWaiterHash

muffVec

private Earmuffs muffVec

tmpWaiter

private Waiter tmpWaiter

socket

private java.net.Socket socket

time

static final int time
Constructor Detail

MessageReceiver

public MessageReceiver(ClientControls clientControls,
                       ChatStreamTokenizer tokenizer,
                       java.net.Socket socket)
Constructor of the class MessageReceiver.
Parameters:
outputArea - TextArea where the received messages are put out.
reader - BufferedReader where the messages are received from.
socket - Socket connected to the server.
Method Detail

getTimeout

public int getTimeout()
return the Timeout
Returns:
time the time to which the timeout is set. After invoking getTimout() you have to wait for time time in seconds; you understand ??

run

public void run()
Overrides the method run() in Thread.
Overrides:
run in class java.lang.Thread

readCommand

private java.util.Vector readCommand(ChatStreamTokenizer tokenizer)
                              throws java.io.IOException
Fetch one command from the input.
Parameters:
tokenizer - ChatStreamTokenizer which reads the command.
Returns:
a Vector containing the command.

setDisconnect

public void setDisconnect()
Give the MessageReceiver the signal to stop receiving. You must call this method to ensure that the MessageReceiver stops taking chars from the InputStream.

getReplyWaiter

public Waiter getReplyWaiter(java.lang.String msg)
returns a waiter thread which will wait for the event specified in msg, see Waiter for details.
Parameters:
msg - the message to wait for (e.g. LeaveReply)

handleNormalRequests

public void handleNormalRequests(java.util.Vector tokenlist)
handles all Requests
Parameters:
tokenlist - is the Vector that is read by the tokenizer