3 from .util
import guess_hostname
11 A vertex in a ported graph with ZIO edges 14 def __init__(self, nick, origin=0, hostname='127.0.0.1'):
18 A node has a nickname. It may assert a unique origin number. 19 A hostname may be specified for default binds of its ports or 20 one will attempt to be autodetected. 28 sp =
' '.join([str(p)
for p
in self.
ports.values()])
29 return "[node %s]: origin:%d ports:[%s]" % (self.
nick, self.
origin, sp)
31 def port(self, name, stype=None):
35 If the port with this name exists, return it. Otherwise, 36 create one with the given ZeroMQ socket type. 38 if name
in self.
ports:
39 return self.
ports[name]
41 raise KeyError(
'No port "%s"' % name)
44 self.
ports[name] = port
51 The node will advertise a number of ZIO headers based on the 52 ports that have been prepared. Additional application headers 55 if hasattr(self,
"peer"):
56 print (
'Node "%s" already online' % self.
nick)
59 for port
in self.
ports.values():
63 for port
in self.
ports.values():
64 port.online(self.
peer)
71 This will cause all ports to disconnect and unbind and the 75 for port
in self.
ports.values():
78 if hasattr(self,
"peer"):
def __init__(self, nick, origin=0, hostname='127.0.0.1')
def online(self, headers)
def port(self, name, stype=None)