lexx.server
Class Chat

java.lang.Object
  |
  +--lexx.server.Chat

public final class Chat
extends java.lang.Object

Static factory class for handling messages between client/sertver

Copyright (c) 2002-2003

Since:
25/02/2003
Version:
1.0
Author:
Mohammed Imran

Field Summary
static long receieved
           
static long sent
           
 
Constructor Summary
Chat()
           
 
Method Summary
static java.io.File createFile(java.lang.String message, java.lang.String outputDir, boolean urlDec)
          Interprets a message sent from client/sever
static int getClientNum(java.lang.String message)
          Interprets a message sent from client/sever
static HashProperties getHashProperties(java.lang.String message)
          Interprets a message sent from client/sever
static java.lang.String getMessage(java.io.InputStream in)
           
static RequestedFile getRequestedFile(java.lang.String message)
          Interprets a message sent from client/sever
static java.lang.String getSendFileName(java.lang.String message)
          Interprets a message sent from client/sever
static java.net.ServerSocket getServerSocket(int port)
           
static java.net.Socket getSocket(java.lang.String host, int port)
           
static java.lang.String getUTFMessage(java.io.DataInputStream remoteIn)
           
static java.lang.String recievedMessage(java.lang.String message)
          Interprets a message sent from client/sever
static java.lang.String sendClientNum(int num)
          Sends message to server/client
static java.lang.String sendFile(java.io.File f, java.lang.String outputDir, boolean urlEnc)
          Sends file to client/server
static java.lang.String sendHashProperties(HashProperties hash)
          Sends message to server/client
static java.lang.String sendMeFile(java.lang.String filename)
           
static java.lang.String sendMeHash()
          Sends the message to tell the client/server to send its hash properties
static java.lang.String sendMessage(java.lang.String message)
          Sends message to server/client
static void sendMessage(java.lang.String s, java.io.OutputStream out)
           
static java.lang.String sendRequestedFile(java.lang.String filename, boolean canHaveFile)
           
static void sendUTFMessage(java.lang.String s, java.io.DataOutputStream remoteOut)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

receieved

public static long receieved

sent

public static long sent
Constructor Detail

Chat

public Chat()
Method Detail

sendMeFile

public static final java.lang.String sendMeFile(java.lang.String filename)

getSendFileName

public static final java.lang.String getSendFileName(java.lang.String message)
Interprets a message sent from client/sever

Parameters:
message - message sent from the client/server
Returns:
name of the file

sendMeHash

public static final java.lang.String sendMeHash()
Sends the message to tell the client/server to send its hash properties

Returns:
Sends the message to tell the client/server to send its hash properties

sendMessage

public static final java.lang.String sendMessage(java.lang.String message)
Sends message to server/client

Parameters:
message - the piece of text you want to send to the other client in instant messaging
Returns:
encodes the message

recievedMessage

public static final java.lang.String recievedMessage(java.lang.String message)
Interprets a message sent from client/sever

Parameters:
message - message sent from the client/server
Returns:
chat message used in instant messaging

sendClientNum

public static final java.lang.String sendClientNum(int num)
Sends message to server/client

Returns:
encodes the message

getClientNum

public static final int getClientNum(java.lang.String message)
Interprets a message sent from client/sever

Parameters:
message - message sent from the client/server
Returns:
number of clients that are connected to server

sendHashProperties

public static final java.lang.String sendHashProperties(HashProperties hash)
Sends message to server/client

Returns:
encodes the message

getHashProperties

public static final HashProperties getHashProperties(java.lang.String message)
Interprets a message sent from client/sever

Parameters:
message - message sent from the client/server
Returns:
hash properties i.e. the files that the server/client has

createFile

public static final java.io.File createFile(java.lang.String message,
                                            java.lang.String outputDir,
                                            boolean urlDec)
Interprets a message sent from client/sever

Parameters:
message - message sent from the client/server
outputDir - place where you would like to store the file sent by server
urlDec - determines how the text was encoded
Returns:
file that has just been created

sendFile

public static final java.lang.String sendFile(java.io.File f,
                                              java.lang.String outputDir,
                                              boolean urlEnc)
Sends file to client/server

Parameters:
f - file you wish to sent
outputDir - project directory
urlEnc - type of encoding
Returns:
encodes the message

getRequestedFile

public static final RequestedFile getRequestedFile(java.lang.String message)
Interprets a message sent from client/sever

Parameters:
message - message sent from the client/server
Returns:
the name of the file that the client/server wants, and where he/she can have it

getUTFMessage

public static java.lang.String getUTFMessage(java.io.DataInputStream remoteIn)
                                      throws java.io.IOException
java.io.IOException

sendUTFMessage

public static void sendUTFMessage(java.lang.String s,
                                  java.io.DataOutputStream remoteOut)
                           throws java.io.IOException
java.io.IOException

getServerSocket

public static java.net.ServerSocket getServerSocket(int port)

getSocket

public static java.net.Socket getSocket(java.lang.String host,
                                        int port)

getMessage

public static java.lang.String getMessage(java.io.InputStream in)
                                   throws java.io.IOException
java.io.IOException

sendMessage

public static void sendMessage(java.lang.String s,
                               java.io.OutputStream out)
                        throws java.io.IOException
java.io.IOException

sendRequestedFile

public static final java.lang.String sendRequestedFile(java.lang.String filename,
                                                       boolean canHaveFile)