networking.server
Class FileUploadServer

java.lang.Object
  extended by java.lang.Thread
      extended by networking.base.ForkedThread
          extended by networking.base.SocketThread
              extended by networking.server.Server
                  extended by networking.server.FileServer
                      extended by networking.server.FileUploadServer
All Implemented Interfaces:
java.lang.Runnable

 class FileUploadServer
extends FileServer

FileUploadServer - this class represents a server which provides an opportinity to upload files


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int ASK
          ASK state constant - asking clients
static int ERROR
          ERROR state constant - file transfer failed
private  int m_activeCount
          Active recipients count, i.e. those who accepted the file
private  int m_count
          Recipients count
private  int m_state
          Current state
static int READY
          READY state constant - file transfer completed
static int RECV
          RECV state constant - receiving file
 
Fields inherited from class networking.server.FileServer
m_file, m_master, m_msg
 
Fields inherited from class networking.base.SocketThread
s_timeSleep
 
Fields inherited from class networking.base.ForkedThread
CHILD, m_fork, NONE, PARENT
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
FileUploadServer(FileServer s)
          Construct new FileUploadServer object from parent server
 
Method Summary
 void acceptFile()
          Target client indicated accept of the file
 void ackFile()
          FileDownloadServer acknowledges file object receipt
 void ackFileTransfer()
          FileDownloadServer acknowledges file transfer
private  void checkEnd()
          Check if all clients are served
private  void checkFile()
          Check if all active clients are served and delete the file
protected  void error(java.lang.Exception e)
          Report error
 int getServState()
          Get current state
protected  void processMessage(Message msg)
          Process a message
 void rejectFile()
          Target client indicated reject of the file
 void run()
           
private  void setServState(int state)
          Switch to the new state
protected  int translateMessageType(Message msg)
          Translate message type for sending it to clients
 
Methods inherited from class networking.server.FileServer
getFile, getMessage
 
Methods inherited from class networking.server.Server
circulateMessage, getClient, getId, getSignature, log, stop1
 
Methods inherited from class networking.base.SocketThread
deinit, enque, exit, getIn, getOut, init, recv, run1, send, setSocket, setTimeOut, wait
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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
 

Field Detail

ASK

public static final int ASK
ASK state constant - asking clients

See Also:
Constant Field Values

RECV

public static final int RECV
RECV state constant - receiving file

See Also:
Constant Field Values

READY

public static final int READY
READY state constant - file transfer completed

See Also:
Constant Field Values

ERROR

public static final int ERROR
ERROR state constant - file transfer failed

See Also:
Constant Field Values

m_state

private int m_state
Current state


m_count

private int m_count
Recipients count


m_activeCount

private int m_activeCount
Active recipients count, i.e. those who accepted the file

Constructor Detail

FileUploadServer

public FileUploadServer(FileServer s)
Construct new FileUploadServer object from parent server

Parameters:
s - parent server
Method Detail

acceptFile

public void acceptFile()
                throws java.lang.Exception
Target client indicated accept of the file

Throws:
java.lang.Exception

rejectFile

public void rejectFile()
                throws java.lang.Exception
Target client indicated reject of the file

Throws:
java.lang.Exception

ackFile

public void ackFile()
             throws java.lang.Exception
FileDownloadServer acknowledges file object receipt

Throws:
java.lang.Exception

ackFileTransfer

public void ackFileTransfer()
FileDownloadServer acknowledges file transfer


checkFile

private void checkFile()
Check if all active clients are served and delete the file


checkEnd

private void checkEnd()
               throws java.lang.Exception
Check if all clients are served

Throws:
java.lang.Exception

setServState

private void setServState(int state)
Switch to the new state

Parameters:
state - new state

getServState

public final int getServState()
Get current state


translateMessageType

protected int translateMessageType(Message msg)
Description copied from class: Server
Translate message type for sending it to clients

Overrides:
translateMessageType in class Server
Parameters:
msg - message

processMessage

protected void processMessage(Message msg)
                       throws java.lang.Exception
Description copied from class: SocketThread
Process a message

Overrides:
processMessage in class FileServer
Parameters:
msg - message
Throws:
java.lang.Exception

run

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

error

protected void error(java.lang.Exception e)
Description copied from class: SocketThread
Report error

Overrides:
error in class Server
Parameters:
e - exception


Copyright © 2009 Alexey Veremenko. All rights reserved.