Exemple #1
0
    def send(self, node_id, byte_values):
        byte_values = [max(0, min(255, x)) for x in byte_values]

        packet = CommHeader(payload_len=len(byte_values),
                            msgtype="frame_update").get_bytes()
        packet.extend(node_id.to_bytes(4, byteorder="big"))
        packet.extend(byte_values)

        self.udp_handler.send_bytes(node_id, packet)
Exemple #2
0
    def send_request(self, node_id, request):
        # just drop request for unknown clients for now
        if node_id in self.nodes.keys():
            request_bytes = CommHeader(msgtype=request).get_bytes()
            request_bytes.extend(node_id.to_bytes(4, byteorder="big"))

            self.sock.sendto(
                request_bytes,
                (self.nodes[node_id].address, self.nodes[node_id].port))