コード例 #1
0
ファイル: client.py プロジェクト: Try4W/MagicPewPew
 def run(self):
     while self.allow_processing:
         try:
             json_data = messager.recv_msg(self.connection)
         except Exception as e:
             print(e)
             self.client.stop_client()
             sys.exit(1)
         server_objects = client_server_tools.unpack_patch(json_data)
         self.client.update_client_objects_from_server_objects(server_objects)
コード例 #2
0
ファイル: server_objects.py プロジェクト: Try4W/MagicPewPew
        tmp_dict = copy.copy(self.__dict__)
        del tmp_dict["fly_direction"]
        return self.__class__.__name__ + ":" + str(tmp_dict)


if __name__ == "__main__":
    a = ServerPlayer()
    b = ServerFireball(0, 0, 0)
    print("# Object -> json test")
    print(a.to_json())
    print(a.to_json())
    print(b.to_json())
    print(b.to_json())

    import client_server_tools

    print("# dict{uuid: obj} -> json test")
    demo_server_object = {"uuid1": a, "uuid2": b}
    server_objects_json_demo = client_server_tools.pack_patch(demo_server_object)
    print(server_objects_json_demo)

    print("# json -> dict(uuid: obj) test")
    server_objects_demo = client_server_tools.unpack_patch(server_objects_json_demo)
    print(server_objects_demo)

    # import client_objects
    # print("# server_objects -patch-> client_objects")
    # client_objects_demo = {"uuid1": client_objects.Player(None, None), "uuid2": client_objects.Fireball(0)}
    # client_server_tools.update_client_objects_server_objects(client_objects_demo, server_objects_demo)
    # print(client_objects_demo)