aardio 文档

wsock.bt.dhtClient 库模块帮助文档

wsock.bt 成员列表 #

wsock.bt.dhtClient #

BitTorrent DHT 客户端。

此客户端可用于访问 process.aria2 对象的 DHT 服务端口(dhtListeningPort 属性)。

wsock.bt.dhtClient() #

返回对象:wsockBtDhtClientObject

wsock.bt.dhtClient(ports,routingTable) #

创建 DHT 客户端。

wsockBtDhtClientObject 成员列表 #

wsockBtDhtClientObject.nodeId #

DHT 节点 ID

wsockBtDhtClientObject.sendFindNode #

wsockBtDhtClientObject.sendFindNode(ip,port,tagetNodeId,  
    function(nodes) {  
        /*回调参数 nodes 都是 DHT 端点信息数组,每个元素都有 ip,port,nodeId 字段。  

可选用第 3,4 个回调参数接收发送时的 ip,port 参数。  
第 2 个回调参数为保留参数,第 5 个回调函数总是 null 值。  
这样设计参数顺序是为了可以与 sendGetPeers 方法共用一个回调函数。*/  
    }  
)

wsockBtDhtClientObject.sendGetPeers #

wsockBtDhtClientObject.sendGetPeers(ip,port,infoHash,  
    function(nodes,peers) {  
        /*如果找到可获取元数据的端点则回调参数 @peers 为 BT 端点(peer)数组,  
否则回调参数 nodes 返回 DHT 节点信息数组。  
peers 是可以使用 BT 协议连接的端点地址,node 可以使用 DHT 协议连接的端点地址。  
nodes,peers 的格式都是对象数组,每个元素都有 ip,port 字段,  
nodes 元素则会多一个 20 字节的 nodeId 字段(二进制字符串)。  

可选用第 3,4,5 个回调参数接收发送时的 ip,port,infoHash 参数。*/  
    }  
)

wsockBtDhtClientObject 事件列表 #

wsockBtDhtClientObject.onAnnouncePeer(infoHash,ip,port) #

wsockBtDhtClientObject.onAnnouncePeer = function(infoHash,ip,port){
    /*收到 announce peers 请求  
回调参数 @infoHash 为发现的 BT 资源 info hash 值。  
可调用 sendGetPeers 方法获取可下载元数据的 peers*/
}

wsockBtDhtClientObject.onError #

onError = function(msg,code){
    print("DHT Client error:",msg,code);
}

wsockBtDhtClientObject.onGetPeers(infoHash,ip,port) #

wsockBtDhtClientObject.onGetPeers = function(infoHash,ip,port){
    /*收到 get peers 请求。  
回调参数 @infoHash 为发现的 BT 资源 info hash 值。*/
}

wsockBtDhtClientObject.onSoketError #

onSoketError = function(msg,code){
    print("DHT Client socket error:",msg,code);
}

Markdown 格式