def join(self): # TODO: convert the "control plane" to use deferreds using Twisted style callbacks cb, eb = utils.newID(2) self.app.control[cb] = self.onJoin self.mantleDomain.Join(cb, eb) self.app.mainGreenlet = greenlet(self.app.handle) self.app.mainGreenlet.switch(self.mantleDomain)
def __init__(self): self.cb, self.eb = utils.newID(2) self.green = None # Boy does it hurt me to put this here. canReturn needs to have access to the domain # for call returns self.mantleDomain = None # True if this deferred should inform the core of its types once set # Only true for calls self.canReturn = False
def join(self, token=None): # Pass credentials down to the core before attempting to join the # fabric. if token is not None: self.mantleDomain.SetToken(token) # TODO: convert the "control plane" to use deferreds using Twisted style callbacks cb, eb = utils.newID(2) self.app.control[cb] = self.onJoin self.mantleDomain.Join(cb, eb) self.app.mainGreenlet = greenlet(self.app.handle) self.app.mainGreenlet.switch(self.mantleDomain)
def _setHandler(self, endpoint, handler, coreFunction, doesReturn): ''' Register or Subscribe. Invokes targetFunction for the given endpoint and handler. :param coreFunction: the intended core function, either Subscribe or Register :param doesReturn: True if this handler can return a value (is a registration) ''' d, handlerId = Deferred(), utils.newID() self.app.deferreds[d.cb], self.app.deferreds[d.eb] = d, d self.app.handlers[handlerId] = handler, doesReturn coreFunction(endpoint, d.cb, d.eb, handlerId, cumin.reflect(handler)) return d