lmp_server.py 992 B

123456789101112131415161718192021222324252627282930313233343536
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # SPDX-FileCopyrightText: Copyright (C) 2021 MH3SP Server Project
  4. # SPDX-License-Identifier: AGPL-3.0-or-later
  5. """Monster Hunter LMP server."""
  6. from mh.pat import PatServer, PatRequestHandler
  7. from other.utils import server_base, server_main
  8. import mh.pat_item as pati
  9. class LmpServer(PatServer):
  10. """Basic LMP server class."""
  11. pass
  12. class LmpRequestHandler(PatRequestHandler):
  13. """Basic LMP server request handler class."""
  14. def recvAnsConnection(self, packet_id, data, seq):
  15. """AnsConnection packet."""
  16. connection_data = pati.ConnectionData.unpack(data)
  17. self.server.debug("Connection: {!r}".format(connection_data))
  18. if hasattr(connection_data, "pat_ticket"):
  19. self.sendNtcLogin(2, connection_data, seq)
  20. else:
  21. self.sendNtcLogin(1, connection_data, seq)
  22. BASE = server_base("LMP", LmpServer, LmpRequestHandler)
  23. if __name__ == "__main__":
  24. server_main(*BASE)