Babylon Java Chat

Class BabylonServerFileTransfer

java.lang.Object
  extended by java.lang.Thread
      extended by BabylonFileTransfer
          extended by BabylonServerFileTransfer
All Implemented Interfaces:
java.lang.Runnable

public class BabylonServerFileTransfer
extends BabylonFileTransfer

The thread that runs file transfers on the server side. This class inherits from the generic, abstract BabylonFileTransfer class. It accepts incoming file blocks from the sending client, and sends them out to receiving clients in a coordinated way, until all users have either refused or received the file. If there are no more users receiving and the expiry time has been reached (even if there are still users who have neither accepted or declined) the thread terminates.

Author:
Andy McLaughlin

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class BabylonFileTransfer
blockSize, DEFAULT_BLOCKSIZE, expireMins, expiryTime, fileName, receivedAll, receivedBlocks, tmpFile, totalBlocks, totalSize, transFile
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BabylonServerFileTransfer(BabylonServerConnection c, java.lang.String fn, long ts, int tb, int bs, int minutes, java.util.Vector iu)
           
 
Method Summary
 void addUser(BabylonServerConnection c)
          Add an invited user who has accepted the invitation to the list of participating users and begin sending file blocks.
 void cancel()
          Terminate the file transfer.
 boolean removeUser(BabylonServerConnection c)
          Remove a user from the list of participating users.
 void run()
          Loops through all of the transfer users, transferring file blocks to them.
 
Methods inherited from class BabylonFileTransfer
getFileBlock, putFileBlock
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, 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
 

Constructor Detail

BabylonServerFileTransfer

public BabylonServerFileTransfer(BabylonServerConnection c,
                                 java.lang.String fn,
                                 long ts,
                                 int tb,
                                 int bs,
                                 int minutes,
                                 java.util.Vector iu)
Method Detail

run

public void run()
Loops through all of the transfer users, transferring file blocks to them. When all file blocks have been transferred to a user, they are removed from the list. If the user has disconnected, they are removed from the list. When the expiry date has been surpassed and there are no more users in the active list, the thread terminates.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class BabylonFileTransfer

addUser

public void addUser(BabylonServerConnection c)
Add an invited user who has accepted the invitation to the list of participating users and begin sending file blocks.


removeUser

public boolean removeUser(BabylonServerConnection c)
Remove a user from the list of participating users.


cancel

public void cancel()
Terminate the file transfer.


Babylon Java Chat