JML

net.sf.jqql.obsolete
Class FileSender

java.lang.Object
  extended by net.sf.jqql.obsolete.FileWatcher
      extended by net.sf.jqql.obsolete.FileSender
All Implemented Interfaces:
Runnable

public class FileSender
extends FileWatcher
implements Runnable

 file sender class
 文件发送类
 

Author:
luma

Field Summary
protected  FragmentBuffer fb
           
protected  HeartBeatThread hbThread
           
 
Fields inherited from class net.sf.jqql.obsolete.FileWatcher
buffer, condition, fcp, fdp, fileAgentKey, fileAgentToken, fileMD5, fileName, fileNameMD5, fileSize, fileTransferStatus, fragments, FT_NEGOTIATING, FT_NONE, FT_RECEIVING, FT_SAYING_HELLO, FT_SENDING, FT_SENDING_BASIC, FT_SENDING_EOF, hisFileSessionKey, hisInternetIp, hisInternetPort, hisLocalIp, hisMajorPort, hisMinorPort, hisQQ, listeners, localFile, localFileName, log, major, maxFragmentSize, monitor, myFace, myFileSessionKey, myInternetIp, myInternetPort, myLocalIp, myMajorPort, myMinorPort, myQQ, selector, sessionSequence, shutdown, useUdp, window
 
Constructor Summary
FileSender()
           
 
Method Summary
 void abort()
          abort file transfer 取消文件传输
 void finish()
          finish file transfer, process some post event 结束文件传输,处理一些善后事宜
 void initFragmentBuffer(RandomAccessFile file, int size, int fz, int max)
          init fragment buffer 初始化分片缓冲区
 boolean isSuspend()
           
 boolean openLocalFile()
          open local file to read 打开本地文件准备读
 void run()
           
protected  void sayHello(FileControlPacket fcp, ByteBuffer buffer)
          say hello
 void send()
          send buffer content of sender 发送sender的buffer内容
 void send(ByteBuffer buffer)
          send content of buffer 发送buffer中的内容
protected  void sendBasic(FileDataPacket fdp, ByteBuffer buffer)
          send file basic info 发送文件基本信息
protected  void sendEOF(FileDataPacket fdp, ByteBuffer buffer)
          send file EOF info 发送文件EOF信息
protected  void sendFinish(FileDataPacket fdp, ByteBuffer buffer)
          send transfer over info 发送传输结束信息
protected  void sendFragment(FileDataPacket fdp, ByteBuffer buffer)
          fragment which still doesn't get ACK in send window 发送窗口中还没有收到确认的分片
protected  void sendHeartBeat(FileDataPacket fdp, ByteBuffer buffer, char seq)
          send heart beat 发送heart beat
 void sendInitConnectionToDirect()
          send init connection packet direct to direct port of the other side 往对方直接端口发送Init Connection包
 void setSuspend(boolean suspend)
           
 void shutdown()
          close watcher 关闭守望者
 void start()
           start watcher, for receiver, he will choose a link to transfer for sender, he will start two port waiting for reply by the other side 启动守望者,对于接收者,他将选择一条链路进行连接准备传输 对于发送者,他将启动两个端口等待对方应答
 
Methods inherited from class net.sf.jqql.obsolete.FileWatcher
addFileListener, checkCondition, fireFileAbortedEvent, fireFileConnectedEvent, fireFileFinishedEvent, fireFileInProgressEvent, getCondition, getFileAgentKey, getFileAgentToken, getFileMD5, getFileName, getFileNameMD5, getFileSize, getFileTransferStatus, getFragments, getHisFileSessionKey, getHisInternetIp, getHisInternetPort, getHisLocalIp, getHisMajorPort, getHisMinorPort, getHisQQ, getLocalFileName, getLocalFilePath, getMaxFragmentSize, getMyFace, getMyFileSessionKey, getMyInternetIp, getMyInternetPort, getMyLocalIp, getMyMajorPort, getMyMinorPort, getMyQQ, getSessionSequence, getSlideWindow, initSlideWindow, isUseUdp, removeFileListener, setCondition, setFileAgentKey, setFileAgentToken, setFileMD5, setFileName, setFileNameMD5, setFileSize, setFileTransferStatus, setFragments, setHisFileSessionKey, setHisInternetIp, setHisInternetPort, setHisLocalIp, setHisMajorPort, setHisMinorPort, setHisQQ, setLocalFileName, setMaxFragmentSize, setMyFace, setMyFileSessionKey, setMyInternetIp, setMyInternetPort, setMyLocalIp, setMyMajorPort, setMyMinorPort, setMyQQ, setSessionSequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fb

protected FragmentBuffer fb

hbThread

protected HeartBeatThread hbThread
Constructor Detail

FileSender

public FileSender()
Parameters:
client -
Method Detail

openLocalFile

public boolean openLocalFile()
open local file to read 打开本地文件准备读

Specified by:
openLocalFile in class FileWatcher
Returns:
true表示成功,false表示失败 // true means success, false means fail

shutdown

public void shutdown()
Description copied from class: FileWatcher
close watcher 关闭守望者

Specified by:
shutdown in class FileWatcher

abort

public void abort()
Description copied from class: FileWatcher
abort file transfer 取消文件传输

Specified by:
abort in class FileWatcher

run

public void run()
Specified by:
run in interface Runnable

sendInitConnectionToDirect

public void sendInitConnectionToDirect()
send init connection packet direct to direct port of the other side 往对方直接端口发送Init Connection包


finish

public void finish()
Description copied from class: FileWatcher
finish file transfer, process some post event 结束文件传输,处理一些善后事宜

Specified by:
finish in class FileWatcher

start

public void start()
Description copied from class: FileWatcher
 start watcher, for receiver, he will choose a link to transfer
 for sender, he will start two port waiting for reply by the other side
 启动守望者,对于接收者,他将选择一条链路进行连接准备传输
 对于发送者,他将启动两个端口等待对方应答
 

Specified by:
start in class FileWatcher

initFragmentBuffer

public void initFragmentBuffer(RandomAccessFile file,
                               int size,
                               int fz,
                               int max)
init fragment buffer 初始化分片缓冲区

Parameters:
file - RandomAccessFile对象 // RandomAccessFile object
size - buffer大小 // buffer size
fz - 分片大小 // fragment size
max - 文件最大的分片序号 //sequence number of biggest fragment of file

send

public void send()
send buffer content of sender 发送sender的buffer内容


send

public void send(ByteBuffer buffer)
send content of buffer 发送buffer中的内容


sendHeartBeat

protected void sendHeartBeat(FileDataPacket fdp,
                             ByteBuffer buffer,
                             char seq)
send heart beat 发送heart beat

Parameters:
seq - 序号 //sequence number

sayHello

protected void sayHello(FileControlPacket fcp,
                        ByteBuffer buffer)
say hello


sendFragment

protected void sendFragment(FileDataPacket fdp,
                            ByteBuffer buffer)
fragment which still doesn't get ACK in send window 发送窗口中还没有收到确认的分片


sendEOF

protected void sendEOF(FileDataPacket fdp,
                       ByteBuffer buffer)
send file EOF info 发送文件EOF信息


sendBasic

protected void sendBasic(FileDataPacket fdp,
                         ByteBuffer buffer)
send file basic info 发送文件基本信息


sendFinish

protected void sendFinish(FileDataPacket fdp,
                          ByteBuffer buffer)
send transfer over info 发送传输结束信息


isSuspend

public boolean isSuspend()
Returns:
Returns the suspend.

setSuspend

public void setSuspend(boolean suspend)
Parameters:
suspend - The suspend to set.

JML