def send(self, command): def error_handler(e): self.log.error("DatagramCommandSender failed ", exc_info=True) raise e bytes_sent = 0 serialized_command = Command.serialize(command) bytes_sent += self.source.send(str(len(serialized_command)), error_handler) bytes_sent += self.source.send(serialized_command, error_handler) return bytes_sent
def next_command(self, delta): command = self.command_receiver.next_command(delta) if not self.is_running(): self.logger.warning('DecodingCommandReceiver: poll while not running; returning empty command') return Command(delta) assert command if command.is_valid(): command = self.decoder.decode(command) assert command return command
def next_command(self, delta): def error_handler(e): self.log.error("DatagramCommandReceiver failed ", exc_info=True) raise e command_size = int(self.source.receive(4, error_handler)) assert command_size > 0 serialized_command = '' serialized_command = self.source.receive(command_size, error_handler) command = Command.deserialize(serialized_command) command.delta = delta return command
def next_command(self, delta): return Command(delta)