本文整理汇总了Python中querier.Querier.set_on_nodes_found_callback方法的典型用法代码示例。如果您正苦于以下问题:Python Querier.set_on_nodes_found_callback方法的具体用法?Python Querier.set_on_nodes_found_callback怎么用?Python Querier.set_on_nodes_found_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类querier.Querier
的用法示例。
在下文中一共展示了Querier.set_on_nodes_found_callback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from querier import Querier [as 别名]
# 或者: from querier.Querier import set_on_nodes_found_callback [as 别名]
def __init__(self, dht_addr):
my_addr = dht_addr
my_id = identifier.RandomId()
my_node = Node(my_addr, my_id)
tracker_ = tracker.Tracker()
token_m = token_manager.TokenManager()
self.reactor = ThreadedReactor()
rpc_m = RPCManager(self.reactor, my_addr[1])
querier_ = Querier(rpc_m, my_id)
routing_m = RoutingManager(my_node, querier_,
bootstrap_nodes)
responder_ = Responder(my_id, routing_m,
tracker_, token_m)
responder_.set_on_query_received_callback(
routing_m.on_query_received)
querier_.set_on_response_received_callback(
routing_m.on_response_received)
querier_.set_on_error_received_callback(
routing_m.on_error_received)
querier_.set_on_timeout_callback(routing_m.on_timeout)
querier_.set_on_nodes_found_callback(routing_m.on_nodes_found)
routing_m.do_bootstrap()
rpc_m.add_msg_callback(QUERY,
responder_.on_query_received)
self.lookup_m = LookupManager(my_id, querier_,
routing_m)
self._routing_m = routing_m
示例2: __init__
# 需要导入模块: from querier import Querier [as 别名]
# 或者: from querier.Querier import set_on_nodes_found_callback [as 别名]
class Controller:
def __init__(self, dht_addr):
self.my_addr = dht_addr
self.my_id = identifier.RandomId()
self.my_node = Node(self.my_addr, self.my_id)
self.tracker = tracker.Tracker()
self.token_m = token_manager.TokenManager()
self.reactor = ThreadedReactor()
self.rpc_m = RPCManager(self.reactor, self.my_addr[1])
self.querier = Querier(self.rpc_m, self.my_id)
self.routing_m = RoutingManager(self.my_node, self.querier,
bootstrap_nodes)
self.responder = Responder(self.my_id, self.routing_m,
self.tracker, self.token_m)
self.responder.set_on_query_received_callback(
self.routing_m.on_query_received)
self.querier.set_on_response_received_callback(
self.routing_m.on_response_received)
self.querier.set_on_error_received_callback(
self.routing_m.on_error_received)
self.querier.set_on_timeout_callback(self.routing_m.on_timeout)
self.querier.set_on_nodes_found_callback(self.routing_m.on_nodes_found)
self.routing_m.do_bootstrap()
self.rpc_m.add_msg_callback(QUERY,
self.responder.on_query_received)
self.lookup_m = LookupManager(self.my_id, self.querier,
self.routing_m)
def start(self):
self.reactor.start()
def stop(self):
#TODO2: stop each manager
self.reactor.stop()
def get_peers(self, info_hash, callback_f, bt_port=None):
return self.lookup_m.get_peers(info_hash, callback_f, bt_port)