f00f.net.irc.martyr.dcc
Class DccSendHandler

java.lang.Object
  extended by java.lang.Thread
      extended by f00f.net.irc.martyr.dcc.DccSendHandler
All Implemented Interfaces:
java.lang.Runnable

public class DccSendHandler
extends java.lang.Thread

A DccSendHandler manages a DCC "send" (to us) file transfer. If you wish to use this class to handle a DCC session, provide an implementation for getStreamForReceive in a subclass.

See Also:
AutoDccSetup.getDccSendHandler(java.net.Socket, java.lang.String, int), getStreamForReceive(java.lang.String, int)

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 java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DccSendHandler(java.net.Socket socket, java.lang.String filename, int filesize)
           
 
Method Summary
protected  java.io.OutputStream getStreamForReceive(java.lang.String filename, int filesize)
          This method should return an output stream that a file can be placed into.
protected  void handleDccSend(java.net.Socket socket, java.lang.String filename, int filesize)
          A call to this method means that a connection has been established and processing the file should commence.
 void run()
           
 
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

DccSendHandler

public DccSendHandler(java.net.Socket socket,
                      java.lang.String filename,
                      int filesize)
Method Detail

handleDccSend

protected void handleDccSend(java.net.Socket socket,
                             java.lang.String filename,
                             int filesize)
                      throws java.io.IOException
A call to this method means that a connection has been established and processing the file should commence. Note that normally one would not override this method, but rather, override getStreamForReceive.

Parameters:
socket - Socket ove which send will be handled
filename - Name of file to be sent
filesize - Size of file to send
Throws:
java.io.IOException - if connection could not be established
See Also:
getStreamForReceive(java.lang.String, int)

getStreamForReceive

protected java.io.OutputStream getStreamForReceive(java.lang.String filename,
                                                   int filesize)
                                            throws java.io.IOException
This method should return an output stream that a file can be placed into. Default implementation throws a FileNotFoundException. This is the only method you must override (in this class) to provide fully functional DCC file transfers.

Parameters:
filename - Name of file to be received
filesize - Size of file to be received
Returns:
OutputStream for incoming transfer
Throws:
java.io.IOException - of connection could not be established

run

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


Copyright © 2000-2007 Ben Damm, Daniel Henninger, et al.