Beispiel #1
0
 def send_nodes(self, nodes_list, message):
     """ Send the `message` to `nodes_list` nodes
     If nodes_list is None, send to all nodes """
     if nodes_list is None:
         LOGGER.debug("Broadcast: %r", message)
         self.broadcast(message)
     else:
         LOGGER.debug("Send: %r to %r", message, nodes_list)
         for node in nodes_list:
             self._send(node, message)
Beispiel #2
0
    def handle_data(self, data):
        """ Print the data received line by line """

        while True:
            data = self._strip_until_pkt_start(data)
            if not data.startswith('EX\2') or len(data) < self.ZEP_HDR_LEN:
                break
            # length = header length + data['len_byte']
            full_len = self.ZEP_HDR_LEN + ord(data[self.ZEP_HDR_LEN - 1])
            if len(data) < full_len:
                break

            # Extract packet
            pkt, data = data[:full_len], data[full_len:]
            LOGGER.debug('%s;Packet received len: %d', self.hostname, full_len)
            self.pkt_handler(pkt)
            self.aggregator.rx_packets += 1

        return data
    def handle_data(self, data):
        """ Print the data received line by line """

        while True:
            data = self._strip_until_pkt_start(data)
            if not data.startswith('EX\2') or len(data) < self.ZEP_HDR_LEN:
                break
            # length = header length + data['len_byte']
            full_len = self.ZEP_HDR_LEN + ord(data[self.ZEP_HDR_LEN - 1])
            if len(data) < full_len:
                break

            # Extract packet
            pkt, data = data[:full_len], data[full_len:]
            LOGGER.debug('%s;Packet received len: %d', self.hostname, full_len)
            self.pkt_handler(pkt)
            self.aggregator.rx_packets += 1

        return data