rero.dcc
Class Receive

java.lang.Object
  extended byrero.dcc.ProtocolDCC
      extended byrero.dcc.Receive

public class Receive
extends ProtocolDCC


Field Summary
protected  File dumpTo
           
protected  FileOutputStream fileStream
           
protected  long finalSize
           
protected static int PACKET_SIZE
           
protected  long receivedSize
           
protected  long startSize
           
 
Fields inherited from class rero.dcc.ProtocolDCC
DCC_CHAT, DCC_RECEIVE, DCC_SEND, DCC_TIMEOUT, dispatcher, eventData, idleTime, nickname, socket, startTime, state, STATE_CLOSED, STATE_OPEN, STATE_WAIT
 
Constructor Summary
Receive(String _nickname, File _dumpTo, long _finalSize)
          Create a ready to rock and roll receive socket.
 
Method Summary
 void fireError(String description)
           
 void fireEvent(String event, String description)
           
 long getBytesReceived()
          return the number of bytes that have been received thus far
 long getExpectedSize()
          return the expected size of the file we are receiving
 File getFile()
          return the object pointing to the File we are downloading
 long getStartOffset()
          return the number of bytes that we started out with (0 normally, however in the case of a resume this number could be anything from 0 up to nearly the size of the file
 long getTimeRemaining()
          return the estimated time remaning in seconds
 int getTransferRate()
          return the number of bytes transferred per second
 int getTypeOfDCC()
          return the type of DCC based on a constant
 void pleaseResume()
           
 void run()
           
 void setFile(File f)
           
 
Methods inherited from class rero.dcc.ProtocolDCC
announceFramework, close, getIdleTime, getLocalPort, getNickname, getPort, getRemoteAddress, getStartTime, getState, getTotalTime, isConnected, setDCCSocket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKET_SIZE

protected static int PACKET_SIZE

dumpTo

protected File dumpTo

fileStream

protected FileOutputStream fileStream

receivedSize

protected long receivedSize

finalSize

protected long finalSize

startSize

protected long startSize
Constructor Detail

Receive

public Receive(String _nickname,
               File _dumpTo,
               long _finalSize)
Create a ready to rock and roll receive socket. It is assumed that the File object is either cleared or ready to be resumed. An overwrite command should delete the file first and then start dumping to it. Hopefully this is a safe way to go. Eh?

Method Detail

getBytesReceived

public long getBytesReceived()
return the number of bytes that have been received thus far


getExpectedSize

public long getExpectedSize()
return the expected size of the file we are receiving


getFile

public File getFile()
return the object pointing to the File we are downloading


getTimeRemaining

public long getTimeRemaining()
return the estimated time remaning in seconds


setFile

public void setFile(File f)

pleaseResume

public void pleaseResume()

getStartOffset

public long getStartOffset()
return the number of bytes that we started out with (0 normally, however in the case of a resume this number could be anything from 0 up to nearly the size of the file


getTransferRate

public int getTransferRate()
return the number of bytes transferred per second


getTypeOfDCC

public int getTypeOfDCC()
Description copied from class: ProtocolDCC
return the type of DCC based on a constant

Specified by:
getTypeOfDCC in class ProtocolDCC

run

public void run()
Specified by:
run in class ProtocolDCC

fireEvent

public void fireEvent(String event,
                      String description)

fireError

public void fireError(String description)
Specified by:
fireError in class ProtocolDCC