Exemplo n.º 1
0
	def handle_send_method(self, packet_json):
		self.log_event("send")

		if self.role == 'src':
			self.player.result.src_transmit_packets += 1
			payload = True
		else:
			self.player.result.dst_transmit_packets += 1
			payload = False

		data = RadioPacket.from_json(packet_json).data
		return self.radio.send(data, payload)
Exemplo n.º 2
0
    def handle_send_method(self, packet_json):
        self.log_event("send")

        if self.role == 'src':
            self.player.result.src_transmit_packets += 1
            payload = True
        else:
            self.player.result.dst_transmit_packets += 1
            payload = False

        data = RadioPacket.from_json(packet_json).data
        return self.radio.send(data, payload)
Exemplo n.º 3
0
	def recv_loop(self, timeout=1.):
		# some numpy types are not directly serializable to JSON
		timeout = float(timeout)

		while True:
			packet_json = self._client.recv(timeout=timeout)
			if packet_json is None:
				break

			packet = RadioPacket.from_json(packet_json)

			self._safe_call(self.recv, packet)

			yield packet

		if self._client.should_finish():
			raise StopGame