JML

net.sf.jqql.obsolete
Class FileReceiver

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

public class FileReceiver
extends FileWatcher
implements Runnable

 file receiver class
 文件接收类
 

Author:
luma

Field Summary
 
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
FileReceiver()
           
 
Method Summary
 void abort()
          cancel transfers in the middle of file transfers 在文件传输的中间取消掉传输
 void finish()
          after transfer complete, do some post event 在传输完成后做一些善后工作
 void notifyNATPort()
          first connect the opposite side, cause this method would be use in another thread, so not use local variable for * fear clash 首先连接对方,由于这个方法会在另外一个线程中被调用,所以不使用本地的变量以免冲突
 boolean openLocalFile()
          open local file to write 打开本地文件准备写
 void run()
           
 void saveFragment(byte[] buf, int from, int len, long offset)
          write fragment data to file 写入分片数据到文件中
 void saveFragment(byte[] buf, long offset)
          write fragment data to file 写入分片数据到文件中
 void selectPort()
          choose a link to rransfers 选择一条链路进行传输
 void send()
          send content of ByteBuffer 发送ByteBuffer中的内容
 void send(ByteBuffer buffer)
          send content of appointed buffer 发送指定buffer中的内容
 void shutdown()
          close watcher 关闭守望者
 void start()
          base on sender and receiver, choose a connect form to start init 根据发送和接收者的情况,选择一种连接方式开始初始化
 void startMajorPort()
          start listener of major port 启动直接端口的监听
 void startMinorPort()
          start receive sent in local port 开始在本地端口接收发送
 
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
 

Constructor Detail

FileReceiver

public FileReceiver()
Parameters:
client -
Method Detail

start

public void start()
base on sender and receiver, choose a connect form to start init 根据发送和接收者的情况,选择一种连接方式开始初始化

Specified by:
start in class FileWatcher

selectPort

public void selectPort()
choose a link to rransfers 选择一条链路进行传输


startMajorPort

public void startMajorPort()
start listener of major port 启动直接端口的监听


startMinorPort

public void startMinorPort()
start receive sent in local port 开始在本地端口接收发送


run

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

shutdown

public void shutdown()
close watcher 关闭守望者

Specified by:
shutdown in class FileWatcher

abort

public void abort()
cancel transfers in the middle of file transfers 在文件传输的中间取消掉传输

Specified by:
abort in class FileWatcher

finish

public void finish()
after transfer complete, do some post event 在传输完成后做一些善后工作

Specified by:
finish in class FileWatcher

saveFragment

public void saveFragment(byte[] buf,
                         long offset)
write fragment data to file 写入分片数据到文件中

Parameters:
buf - 数据缓冲 // data buffer
offset - 数据在实际文件中的绝对偏移 // absolute offset of data in factual file

saveFragment

public void saveFragment(byte[] buf,
                         int from,
                         int len,
                         long offset)
write fragment data to file 写入分片数据到文件中

Parameters:
buf - 包含数据的缓冲区 // data buffer
from - 从缓冲区的from位置开始为分片数据 // from from position of buffer is fragment data
len - 从缓冲区的from位置开始的len字节为分片数据 // len byte from from positio is fragment data
offset - 这段分片在实际文件中的绝对偏移 // absolute offset of fragment in factual file

openLocalFile

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

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

send

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


send

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

Parameters:
buffer -

notifyNATPort

public void notifyNATPort()
first connect the opposite side, cause this method would be use in another thread, so not use local variable for * fear clash 首先连接对方,由于这个方法会在另外一个线程中被调用,所以不使用本地的变量以免冲突


JML