def __init__(self, Ks, cert): '''Construct a new network object. The application must invoke bind() before using any other function on this object. The private key Ks and certificate cert must be supplied to construct a network object.''' Network.count = Network.count + 1 self.name = 'Network[%d]' % (Network.count) self.queue = multitask.SmartQueue( ) # module's default queue for dispatching and receiving Message events self.qsip = multitask.SmartQueue() # queue for SIP messages self.qstun = multitask.SmartQueue() # queue for STUN-related messages self.Ks, self.cert = Ks, cert self.udp, self.tcp, self.mcast = createSockets(preferred=(ADDRESS, PORT)) self.tcp.listen(5) self.tcpc = dict( ) # table of client connections from Node to connected socket if any. ip, port = getlocaladdr(self.udp) ignore, ptcp = getlocaladdr(self.tcp) self.node = Node(ip=ip, port=port, type=socket.SOCK_DGRAM, guid=H(ip + ':' + str(port))) # TODO: construct this using H(Kp) self.nodetcp = Node(ip=ip, port=ptcp, type=socket.SOCK_STREAM, guid=self.node.guid) self.nodemcast = Node(ip=ADDRESS, port=PORT, type=socket.SOCK_DGRAM, guid=self.node.guid) self.gen = self.gentcp = self.genmcast = None
def create(self, nc, timeout=None): self.nc = nc result, fault = yield self.nc.client.send(Command(name='createStream'), timeout=timeout) if _debug: print 'createStream result=', result, 'fault=', fault if result: stream = self.stream = Stream(self.nc.client) stream.queue, stream.id = multitask.SmartQueue(), int(result.args[0]) # replace with SmartQueue self.nc.client.streams[stream.id] = stream raise StopIteration, self else: raise StopIteration, None
def __init__(self, sock): # similar to the Client class of rtmp.py Protocol.__init__(self, sock) self.streams, self.objectEncoding, self._nextCallId, self.queue = {}, 0.0, 1, multitask.SmartQueue( )
def __init__(self): self.url = self.type = self.mode = None self.queue = multitask.SmartQueue()
def __init__(self): self.url = self.type = self.mode = None; self.queue = multitask.SmartQueue() def get(self, timeout=None, criteria=None): result = yield self.queue.get(timeout=timeout, criteria=criteria); raise StopIteration, result
def __init__(self, **kwargs): # type, to, frm super(History, self).__init__(**kwargs) self._init, self._queue = False, multitask.SmartQueue()