return None
class RIIntroducer(RemoteInterface):
- def hello(node=RIIntroducerClient, furl=FURL):
+ def hello(node=RIIntroducerClient, furl=ChoiceOf(FURL, None)):
return None
class RIClient(RemoteInterface):
def _remove():
log.msg(" introducer: removing %s %s" % (node, furl))
self.nodes.remove(node)
- self.furls.remove(furl)
+ if furl is not None:
+ self.furls.remove(furl)
node.notifyOnDisconnect(_remove)
- self.furls.add(furl)
+ if furl is not None:
+ self.furls.add(furl)
+ for othernode in self.nodes:
+ othernode.callRemote("new_peers", set([furl]))
node.callRemote("new_peers", self.furls)
if self._encoding_parameters is not None:
node.callRemote("set_encoding_parameters",
self._encoding_parameters)
- for othernode in self.nodes:
- othernode.callRemote("new_peers", set([furl]))
self.nodes.add(node)
class IntroducerClient(service.Service, Referenceable):
self.reconnectors[furl] = self.tub.connectTo(furl, _got_peer)
def _got_introducer(self, introducer):
- self.log("introducing ourselves: %s, %s" % (self, self.my_furl[6:13]))
+ if self.my_furl:
+ my_furl_s = self.my_furl[6:13]
+ else:
+ my_furl_s = "<none>"
+ self.log("introducing ourselves: %s, %s" % (self, my_furl_s))
self._connected = True
d = introducer.callRemote("hello",
node=self,
i.setServiceParent(self.parent)
iurl = tub.registerReference(i)
NUMCLIENTS = 5
+ # we have 5 clients who publish themselves, and an extra one which
+ # does not. When the connections are fully established, all six nodes
+ # should have 5 connections each.
clients = []
tubs = {}
- for i in range(NUMCLIENTS):
+ for i in range(NUMCLIENTS+1):
tub = Tub()
#tub.setOption("logLocalFailures", True)
#tub.setOption("logRemoteFailures", True)
tub.setLocation("localhost:%d" % portnum)
n = FakeNode()
- node_furl = tub.registerReference(n)
+ log.msg("creating client %d: %s" % (i, tub.getShortTubID()))
+ if i < NUMCLIENTS:
+ node_furl = tub.registerReference(n)
+ else:
+ node_furl = None
c = IntroducerClient(tub, iurl, node_furl)
c.setServiceParent(self.parent)