예제 #1
0
 def _recv_packet(self):
     try:
         packet = self.world_packet_receiver.get_next_packet()
         return packet
     except ConnectionResetError:
         LOG.info("Lost connection with " + self.account.name + ".")
         return None
예제 #2
0
 def _accept_clients(self):
     """ Regularly try to access client while looking for interrupts. """
     try:
         while True:
             self._try_accept_client()
     except KeyboardInterrupt:
         LOG.info("KeyboardInterrupt received, stop accepting clients.")
예제 #3
0
 def _accept_clients(self):
     """ Accept incoming clients connections until manual interruption. """
     try:
         while not self.shutdown_flag.is_set():
             self._try_accept_client()
     except KeyboardInterrupt:
         LOG.info("KeyboardInterrupt received, stop accepting clients.")
예제 #4
0
    def _handle_client(self, connection, address):
        """ Start the threaded WorldConnection and add it to the local list. """
        LOG.info("Accepting client connection from " + str(address))
        world_connection = WorldConnection(self, connection)

        with self.world_connections_lock:
            self.world_connections.append(world_connection)

        simple_thread(world_connection.handle_connection)
예제 #5
0
    def start(self):
        LOG.info("Starting world server " + self.realm.name)
        self._listen_clients()

        simple_thread(self._handle_login_server_connection)
        self._accept_clients()

        self.shutdown_flag.set()
        self._stop_listen_clients()
        LOG.info("World server stopped.")
예제 #6
0
 def _recv_packet(self):
     # This assumes that all packets are received in no more or less than one
     # piece, which is a wrong. However, exceptions shouldn't occur often
     # with how short login messages are.
     try:
         data = self.socket.recv(1024)
         return data or None
     except ConnectionError:
         LOG.info("Lost connection.")
         return None
예제 #7
0
    def start(self):
        LOG.info("Starting login server")
        self._start_listen()

        simple_thread(self._accept_realms)
        self._accept_clients()

        self.shutdown_flag.set()
        self._stop_listen()
        AccountSessionManager.delete_all_sessions()
        LOG.info("Login server stopped.")
예제 #8
0
파일: main.py 프로젝트: Shgck/DuratorEmu
def main():
    LOG.info("DuratorEmu - WoW 1.1.2.4125 Sandbox Server - Shgck 2016")

    argparser = argparse.ArgumentParser()
    argparser.add_argument("module", type = str, help = "module to start")
    args = argparser.parse_args()

    if args.module in MODULES:
        module_class = MODULES[args.module]
        module = module_class()
        module.start()
    else:
        print("Unknown module:", args.module)
예제 #9
0
파일: manager.py 프로젝트: Shgck/DuratorEmu
    def join_channel(self, player, chan_name, password):
        """ Try to add player to this channel with this password.

        Return:
        - 0 on success
        - 1 if the password is wrong
        """
        if chan_name not in self.get_channels_names():
            self.create_channel(chan_name, password)

        # This call assumes that after create_channel, the chan always exists.
        channel = self.get_channel(chan_name)
        if password == channel.password:
            with player.lock:
                player_guid = player.guid
                player_name = player.name
            LOG.info("{} joins channel '{}'.".format(player_name, channel.name))
            channel.add_member(player_guid)
            self._notify_join(channel, player_guid)
            return 0
        else:
            self.clean(chan_name)
            return 1
예제 #10
0
파일: manager.py 프로젝트: Shgck/DuratorEmu
    def leave_channel(self, player, chan_name):
        """ Try to leave channel.

        Return:
        - 0 on success
        - 1 if player wasn't on that channel to begin with
        - 2 if the channel doesn't even exist
        """
        if chan_name not in self.get_channels_names():
            return 2
        channel = self.get_channel(chan_name)

        with player.lock:
            player_guid = player.guid
            player_name = player.name

        if player_guid not in channel.get_members():
            return 1

        LOG.info("{} leaves channel '{}'.".format(player_name, channel.name))
        channel.remove_member(player_guid)
        self._notify_leave(channel, player_guid)
        return 0
예제 #11
0
 def start(self):
     LOG.info("Database client started. Type help for a list of commands.")
     self._shell()
예제 #12
0
 def _handle_client(self, connection, address):
     """ Start another thread to securely handle the client connection. """
     LOG.info("Accepting client connection from " + str(address))
     login_connection = LoginConnection(self, connection)
     simple_thread(login_connection.handle_connection)