(self, basestation, callback, timeout=120)
Use this method to subscribe to the event stream and provide a callback that will be called for event event received.
        This function will allow you to potentially write a callback that can handle all of the events received from the event stream.
Use this method to subscribe to the event stream and provide a callback that will be called for event event received.
        This function will allow you to potentially write a callback that can handle all of the events received from the event stream.
Use this method to subscribe to the event stream and provide a callback that will be called for event event received . This function will allow you to potentially write a callback that can handle all of the events received from the event stream .
def HandleEvents(self, basestation, callback, timeout=120):
        """
        Use this method to subscribe to the event stream and provide a callback that will be called for event event received.
        This function will allow you to potentially write a callback that can handle all of the events received from the event stream.
        """
        if not callable(callback):
            raise Exception('The callback(self, event) should be a callable function.')

        basestation_id = basestation.get('deviceId')

        self.Subscribe(basestation)
        if self.event_stream and self.event_stream.connected and self.event_stream.registered:
            while self.event_stream.connected:
                event = self.event_stream.Get(timeout=timeout)
                if event is None or self.event_stream.event_stream_stop_event.is_set():
                    return None

                # If this event has is of resource type "subscriptions", then it's a ping reply event.
                # For now, these types of events will be requeued, since they are generated in response to and expected as a reply by the Ping() method.
                # HACK: Take a quick nap here to give the Ping() method's thread a chance to get the queued event.
                if event.get('resource', '').startswith('subscriptions'):
                    self.event_stream.queue.put(event)
                    time.sleep(0.05)
                else:
                    response = callback(self, event)
                    # NOTE: Not ideal, but this allows you to look for a specific event and break if you want to return it.
                    if response is not None:
                        return response
def HandleEvents ( self , basestation , callback , timeout = 120 ) : if not callable ( callback ) : raise Exception ( 'The callback(self, event) should be a callable function.' ) basestation_id = basestation . get ( 'deviceId' ) self . Subscribe ( basestation ) if self . event_stream and self . event_stream . connected and self . event_stream . registered : while self . event_stream . connected : event = self . event_stream . Get ( timeout = timeout ) if event is None or self . event_stream . event_stream_stop_event . is_set ( ) : return None # If this event has is of resource type "subscriptions", then it's a ping reply event. # For now, these types of events will be requeued, since they are generated in response to and expected as a reply by the Ping() method. # HACK: Take a quick nap here to give the Ping() method's thread a chance to get the queued event. if event . get ( 'resource' , '' ) . startswith ( 'subscriptions' ) : self . event_stream . queue . put ( event ) time . sleep ( 0.05 ) else : response = callback ( self , event ) # NOTE: Not ideal, but this allows you to look for a specific event and break if you want to return it. if response is not None : return response