def read_packet(self, client_file): buffer = self.read_packet_buffer(client_file) packet_id = types.VarInt.read(buffer) if packet_id in self.packets: packet = self.packets[packet_id](self.context) packet.read(buffer) else: packet = packets.Packet(self.context, id=packet_id) logging.debug('[ ->S] %s' % packet) return packet
def read_packet(self): # Read and log a serverbound packet from the client, or raises # FakeClientDisconnect if the client has cleanly disconnected. buffer = self._read_packet_buffer() packet_id = types.VarInt.read(buffer) if packet_id in self.packets: packet = self.packets[packet_id](self.server.context) packet.read(buffer) else: packet = packets.Packet(self.server.context, id=packet_id) logging.debug('[ ->S] %s' % packet) return packet