def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param Frame frame: the Frame object to transmit """ with self.__listeners_change_condition: listeners = list(self.listeners.values()) for listener in listeners: if not listener: continue try: listener.on_send(frame) except AttributeError: continue lines = utils.convert_frame_to_lines(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame: %s", lines) else: log.info("Sending frame: %r, headers=%r", frame.cmd or "heartbeat", utils.clean_headers(frame.headers)) self.send(encode(packed_frame))
def transmit(self, frame): """ Convert a frame object to a frame string and transmit to the server. :param Frame frame: the Frame object to transmit """ for listener in self.listeners.values(): if not listener: continue try: listener.on_send(frame) except AttributeError: continue lines = utils.convert_frame_to_lines(frame) packed_frame = pack(lines) if log.isEnabledFor(logging.DEBUG): log.debug("Sending frame: %s", lines) else: log.info("Sending frame: %r, headers=%r", frame.cmd or "heartbeat", utils.clean_headers(frame.headers)) self.send(encode(packed_frame))
def on_send(self, frame): """ :param Frame frame: """ print('on_send %s %s %s' % (frame.cmd, utils.clean_headers(frame.headers), frame.body))
def on_send(self, frame): """ :param Frame frame: """ self.__print("on_send %s %s %s", frame.cmd, utils.clean_headers(frame.headers), frame.body)