Пример #1
0
 def __init__(self, server):
     self.server = server
     self.start_time = reactor.seconds()
     self.client_handler = PacketHandler(CS_PACKETS, self.on_client_packet)
     self.server_handler = PacketHandler(SC_PACKETS, self.on_server_packet)
     self.entities = {}
     self.relay_packets = []
     self.print_stats()
     self.times = []
Пример #2
0
 def __init__(self, loop):
     self.loop = loop
     self.start_time = self.loop.time()
     self.client_handler = PacketHandler(CS_PACKETS, self.on_client_packet)
     self.server_handler = PacketHandler(SC_PACKETS, self.on_server_packet)
     self.entities = {}
     self.relay_packets = []
     self.print_stats()
     self.times = []
Пример #3
0
    def connectionMade(self):
        server = self.server
        if len(server.connections) >= server.config.base.max_players:
            self.send_packet(server_full_packet)
            self.disconnect()
            return

        self.packet_handlers = {
            ClientVersion.packet_id: self.on_version_packet,
            EntityUpdate.packet_id: self.on_entity_packet,
            ClientChatMessage.packet_id: self.on_chat_packet,
            InteractPacket.packet_id: self.on_interact_packet,
            HitPacket.packet_id: self.on_hit_packet,
            ShootPacket.packet_id: self.on_shoot_packet
        }

        self.packet_handler = PacketHandler(CS_PACKETS, self.on_packet)

        server.connections.add(self)
        self.rights = AttributeSet()

        self.scripts = ScriptManager()
        server.scripts.call('on_new_connection', connection=self)