swpchat.client
Class FileProtocolHandler

java.lang.Object
  |
  +--swpchat.client.ServerConnection
        |
        +--swpchat.client.FileConnection
              |
              +--swpchat.client.FileProtocolHandler
All Implemented Interfaces:
ChatTokens, ControlTokens, FileServer, FileTransferTokens, ProtocolTokens, java.lang.Runnable, SenderReceiverTokens

public class FileProtocolHandler
extends FileConnection
implements FileServer, FileTransferTokens, java.lang.Runnable

class that handles the FileProtocol with another client

Author:
Andre Brunner, Christian Stuellenberg, Marc Sturm

Field Summary
(package private)  ClientControls clientControls
           
private static java.lang.String CLS
           
private  boolean connected
           
 java.io.BufferedWriter ostream
           
 java.net.Socket socket
           
private static java.lang.String STR_STANDARD
           
private  java.lang.String strFileName
           
private  java.lang.String strFileSize
           
 ChatStreamTokenizer tokenizer
           
 java.util.Vector tokenlist
           
 boolean wait
           
 
Fields inherited from interface swpchat.protocol.FileTransferTokens
STR_SEND_FILE_REQUEST, STR_SEND_FILE_REQUEST_BEGIN, STR_SET_FILENAME, STR_SET_FILENAME_BEGIN, STR_SET_FILESIZE, STR_SET_FILESIZE_BEGIN
 
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
 
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.ControlTokens
STR_EMOTION, STR_LOGIN, STR_LOGIN_BEGIN, STR_LOGIN_RE_BEGIN, STR_LOGOUT, STR_LOGOUT_BEGIN, STR_LOGOUT_RE_BEGIN, STR_MEMBER, STR_MEMBER_BEGIN, STR_MEMBER_INFO, STR_MEMBER_JOIN, STR_MEMBER_LEAVE, STR_MEMBER_SHIP, STR_NEW_CHANNEL, STR_NOTIFICATION, STR_NOTIFICATION_BEGIN, STR_NOTIFY_REQUEST, STR_REMOVE_CHANNEL, STR_RENAME_CHANNEL, STR_REQUEST_IP, STR_REQUST_IP_RE_BEGIN, STR_SEND_USERINFO, STR_SET_NICK, STR_SET_NICK_BEGIN, STR_SET_NICK_RE_BEGIN, STR_SET_SESSIONKEY, STR_STOP_NOTIFICATION, STR_TELEPHONE_REQUEST
 
Fields inherited from interface swpchat.protocol.ProtocolTokens
STR_CONTROL, STR_CONTROL_PROTOCOL_ID, STR_FILE_SEND, STR_FILE_SEND_PROTOCOL_ID, STR_PROTOCOL, STR_PROTOCOL_ID_BEGIN, STR_RECEIVER, STR_RECEIVER_PROTOCOL_ID, STR_SENDER, STR_SENDER_PROTOCOL_ID
 
Constructor Summary
FileProtocolHandler(ClientControls clientControls, java.net.Socket socket)
          Constructor
 
Method Summary
private  void getFileFromInputStream()
          gets file bytes from input stream and works with it.
protected static java.util.Vector readCommand(ChatStreamTokenizer tokenizer, java.net.Socket sourceSocket)
          Fetch one command from the inputStream.
 void run()
           
 void serve(java.net.Socket socket)
          implementation of method serve from ProtocolHandler
 
Methods inherited from class swpchat.client.FileConnection
isLogin, isLoginReply, isSendFileRequest, isSendFileRequestReply, isSetFileName, isSetFileNameReply, isSetFileSize, isSetFileSizeReply
 
Methods inherited from class swpchat.client.ServerConnection
isEmotion, isEmotionReceive, isEmotionReply, isJoinReply, isLeaveReply, isLogoutReply, isMemberInfo, isNegativeRequestUserInfoReply, isNegativeSendUserInfoReply, isNewChannel, isNewChannelReply, isNotification, isPlay, isPlayReply, isPositiveRequestUserInfoReply, isPositiveSendUserInfoReply, isReceive, isReceiveUserInfo, isRemoveChannel, isRemoveChannelReply, isRenameChannel, isRenameChannelReply, isRequestIPAddress, isRequestIPAddressReply, isSendReply, isSendTelephoneRequest, isSendTelephoneRequestReply, isSetNickReply, isSetSessionKeyReply, isSetTopicReply, isShipReceive, isShipReply, isTopicChanged, isWhisperReply, isWhispreceive, readReply, reply, send, send, send, send, writeLine
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CLS

private static final java.lang.String CLS

STR_STANDARD

private static final java.lang.String STR_STANDARD

strFileName

private java.lang.String strFileName

strFileSize

private java.lang.String strFileSize

connected

private boolean connected

wait

public boolean wait

clientControls

ClientControls clientControls

tokenizer

public ChatStreamTokenizer tokenizer

ostream

public java.io.BufferedWriter ostream

socket

public java.net.Socket socket

tokenlist

public java.util.Vector tokenlist
Constructor Detail

FileProtocolHandler

public FileProtocolHandler(ClientControls clientControls,
                           java.net.Socket socket)
Constructor
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

getFileFromInputStream

private void getFileFromInputStream()
gets file bytes from input stream and works with it.

serve

public void serve(java.net.Socket socket)
           throws TimeoutException,
                  java.io.IOException,
                  java.security.InvalidParameterException
implementation of method serve from ProtocolHandler
Specified by:
serve in interface FileServer
Parameters:
{@link - java.net.Socket}, the socket that must be served
{@link - java.io.InputStream}, the Stream that must be read from
Throws:
TimeoutException - thrown if connection to the client is lost or too slow.
java.io.IOException - thrown for any I/O error.
java.security.InvalidParameterException - possibly useful

readCommand

protected static java.util.Vector readCommand(ChatStreamTokenizer tokenizer,
                                              java.net.Socket sourceSocket)
                                       throws TimeoutException,
                                              java.io.IOException
Fetch one command from the inputStream.