def RegisterUniverse(self, universe, action, data_callback, callback=None): """Register to receive dmx updates for a universe. Args: universe: the universe to register to action: OlaClient.REGISTER or OlaClient.UNREGISTER data_callback: the function to be called when there is new data, passed a single argument of type array. callback: The function to call once complete, takes one argument, a RequestStatus object. Returns: True if the request was sent, False otherwise. """ if self._socket is None: return False controller = SimpleRpcController() request = Ola_pb2.RegisterDmxRequest() request.universe = universe request.action = action done = lambda x, y: self._AckMessageComplete(callback, x, y) try: self._stub.RegisterForDmx(controller, request, done) except socket.error: raise OLADNotRunningException() if action == self.PATCH: self._universe_callbacks[universe] = data_callback elif universe in self._universe_callbacks: del self._universe_callbacks[universe] return True
def RegisterUniverse(self, universe, action, data_callback, callback=None): """Register to receive dmx updates for a universe. Args: universe: the universe to set the name of action: OlaClient.REGISTER or OlaClient.UNREGISTER data_callback: the function to be called when there is new data, passed a single argument of type array. callback: The function to call once complete, takes one argument, a RequestStatus object. """ controller = SimpleRpcController() request = Ola_pb2.RegisterDmxRequest() request.universe = universe request.action = action done = lambda x, y: self._AckMessageComplete(callback, x, y) self._stub.RegisterForDmx(controller, request, done) if action == self.PATCH: self._universe_callbacks[universe] = data_callback elif universe in self._universe_callbacks: del self._universe_callbacks[universe]