|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--FishServerHandler
Thread to handle clients interaction with the server.
Nested Class Summary | |
class |
FishServerHandler.FilePost
Post which contains information on the files |
class |
FishServerHandler.SharePost
Post to put in the global dir with info. on the client and its files. |
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
FishServerHandler(java.net.Socket cSocket)
Initializing the in- and outputstream between the client and the server. |
Method Summary | |
void |
addClientShare(java.lang.String ipAddress,
int cSharePort,
java.util.Vector cShare)
Adds a share for the client to the global dir. |
static void |
addFilesSize(long num)
Increase statistics on total size of shared files. |
static void |
addNumFiles(int num)
Increase statistics on total number of shared files. |
static void |
decConnectedClients()
Decrease statistics on number of currently connected clients. |
static int |
getClientsDuringUptime()
Number of clients that have connected to the server since it started. |
static int |
getConnectedClients()
Statistics on number of currently connected clients. |
static long |
getFilesSize()
Statistics on total size of shared files. |
static int |
getNumFiles()
Statistics on total number of shared files. |
static void |
incConnectedClients()
Increase statistics on number of currently connected clients. |
void |
ping()
Respond with statistics when the server is pinged. |
void |
pong()
Check if client is still alive, if not disconnect. |
void |
printLog(java.lang.String text)
Print the unique number for the client and the message in the log window. |
java.lang.String |
readLineLow()
Reads a line from the client and convert it to lowercase. |
java.lang.String |
readLineLowExc()
Reads a line from the client and convert it to lowercase. |
void |
removeClientShare(java.lang.String ipAndPort)
Removes a share for the client in the global dir, by searching the global list with the unique combination of clients IP-address and portnumber. |
static void |
removeFilesSize(long num)
Decrease statistics on total size of shared files. |
static void |
removeNumFiles(int num)
Decrease statistics on total number of shared files. |
void |
run()
Start the thread, and accept incomming commands. |
void |
search()
Search for files in the global list with all clients files. |
void |
shareFiles()
Shared files are put in a vector and associated with client, then to be put in the global searchable list. |
void |
unknownCommand(java.lang.String cmd)
Function to handle invalid or unknown requests. |
void |
unshareFiles()
Unshare clients files when they are not available any longer. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public FishServerHandler(java.net.Socket cSocket)
cSocket
- Socket from the connected client.Method Detail |
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public java.lang.String readLineLow()
public java.lang.String readLineLowExc() throws java.io.IOException
java.io.IOException
- Thrown when read from client fails.public void printLog(java.lang.String text)
text
- Text to be displayd.public void pong()
public void shareFiles()
public void unshareFiles()
public void ping()
public void search()
public void unknownCommand(java.lang.String cmd)
cmd
- Command sent to server.public void addClientShare(java.lang.String ipAddress, int cSharePort, java.util.Vector cShare)
ipAddress
- IP-address where client can be reached.cSharePort
- Portnumber on which client serves download requests.cShare
- Vector containing all files shared from client.public void removeClientShare(java.lang.String ipAndPort)
ipAndPort
- IP-address and portnumber of client connection
concatenated together.public static void incConnectedClients()
public static void decConnectedClients()
public static int getConnectedClients()
public static int getClientsDuringUptime()
public static void addNumFiles(int num)
num
- Number of files added.public static void removeNumFiles(int num)
num
- Number of files removed.public static int getNumFiles()
public static void addFilesSize(long num)
num
- Total size in bytes of share added.public static void removeFilesSize(long num)
num
- Total size in bytes of share removed.public static long getFilesSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |