def _disconnect_notice(self, event): ''' Receives text/disconnect-notice callback. ''' self._closing_state = True # Gets raw data for this event raw = self.read_raw(event) if raw: event = Event(raw) # Gets raw response from Event Content-Length header # and raw buffer raw_response = self.read_raw_response(event, raw) # If rawresponse was found, this is our Event body if raw_response: event.set_body(raw_response) return None
def _api_response(self, event): ''' Receives api/response callback. ''' # Gets raw data for this event. raw = self.read_raw(event) # If raw was found, this is our Event body. if raw: event.set_body(raw) # Wake up waiting command. try: _cmd_uuid, _async_res = self._commands_pool.pop(0) except (IndexError, ValueError): raise InternalSyncError("Cannot wakeup command !") _async_res.set((_cmd_uuid, event)) return None
def _event_plain(self, event): ''' Receives text/event-plain callback. ''' # Gets raw data for this event raw = self.read_raw(event) # If raw was found drops current event # and replaces with Event created from raw if raw: event = Event(raw) # Gets raw response from Event Content-Length header # and raw buffer raw_response = self.read_raw_response(event, raw) # If rawresponse was found, this is our Event body if raw_response: event.set_body(raw_response) # Returns Event return event