From 8ac32ad4d3d7f365f53e25d7dbad54b2879f293c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Charvet=20=E9=BB=91=E7=93=9C?= Date: Sat, 27 Jul 2024 10:25:27 +0100 Subject: [PATCH] Purge almost all mention of tachyon There used to be two prototype versions of the protocol. One TLS based and one Websocket based. None of them were fully functionning and since the departure of Teifion from the project the protocol evolved more. Having legacy code lingering around caused some confusion when trying to understand the server. Note that there may be additional cleanup required. A lot of the tachyon system was based around Coordinator and Consul, and they may or may not be tachyon logic in them. We'll figure that out later. There is one piece of logic that could probably be reused almost as-is: the function `login_from_token` (search the diffs). Swapping the token code for the OAuth based one, the rest should be almost identical. --- config/config.exs | 5 +- config/runtime.exs | 5 +- config/test.exs | 3 +- documents/tachyon/auth.md | 178 --- documents/tachyon/clan.md | 8 - documents/tachyon/client.md | 79 -- documents/tachyon/communication.md | 147 -- documents/tachyon/config.md | 89 -- documents/tachyon/listeners.md | 17 - documents/tachyon/lobby.md | 372 ----- documents/tachyon/lobby_chat.md | 8 - documents/tachyon/lobby_host.md | 91 -- documents/tachyon/matchmaking.md | 126 -- documents/tachyon/news.md | 27 - documents/tachyon/party.md | 219 --- documents/tachyon/readme.md | 42 - documents/tachyon/server_comms.md | 3 - documents/tachyon/system.md | 100 -- documents/tachyon/telemetry.md | 40 - documents/tachyon/types.md | 297 ---- documents/tachyon/user.md | 162 --- lib/teiserver.ex | 6 - lib/teiserver/application.ex | 5 - lib/teiserver/data/cache_user.ex | 94 -- lib/teiserver/data/types.ex | 8 - lib/teiserver/libs/teiserver_configs.ex | 18 - lib/teiserver/protocols/spring/spring_in.ex | 28 - lib/teiserver/protocols/spring/spring_out.ex | 6 +- .../protocols/tachyon_json_ws/cache.ex | 28 - .../tachyon_json_ws/command_dispatch.ex | 63 - .../protocols/tachyon_json_ws/converters.ex | 92 -- .../handlers/account/whoami_request.ex | 26 - .../send_direct_message_request.ex | 25 - .../handlers/lobby/join_request.ex | 25 - .../handlers/lobby/leave_request.ex | 31 - .../handlers/lobby/list_lobbies_request.ex | 28 - .../handlers/lobby/update_status_request.ex | 58 - .../handlers/lobby_chat/say_request.ex | 36 - .../handlers/lobby_host/create_request.ex | 42 - .../respond_to_join_request_request.ex | 29 - .../handlers/system/disconnect_request.ex | 27 - .../handlers/system/force_error_request.ex | 26 - .../system/no_command_error_request.ex | 29 - .../handlers/system/ping_request.ex | 22 - .../handlers/telemetry/event_request.ex | 25 - .../handlers/telemetry/property_request.ex | 25 - .../client_message_handlers.ex | 84 -- .../lobby_chat_message_handlers.ex | 40 - .../lobby_host_message_handlers.ex | 31 - .../lobby_update_message_handlers.ex | 79 -- .../responses/account/whoami_response.ex | 42 - .../received_direct_message_response.ex | 24 - .../send_direct_message_response.ex | 12 - .../lobby/add_user_client_response.ex | 38 - .../responses/lobby/closed_response.ex | 12 - .../responses/lobby/join_response.ex | 22 - .../responses/lobby/joined_response.ex | 18 - .../responses/lobby/leave_response.ex | 12 - .../responses/lobby/list_lobbies_response.ex | 16 - .../lobby/received_join_request_response.ex | 20 - .../lobby/remove_user_client_response.ex | 18 - .../responses/lobby/update_status_response.ex | 14 - .../responses/lobby_chat/said_response.ex | 18 - .../responses/lobby_chat/say_response.ex | 22 - .../responses/lobby_host/add_bot_response.ex | 14 - .../responses/lobby_host/close_response.ex | 14 - .../responses/lobby_host/create_response.ex | 25 - .../lobby_host/end_battle_response.ex | 14 - .../lobby_host/join_request_response.ex | 15 - .../lobby_host/remove_bot_response.ex | 14 - .../respond_to_join_request_response.ex | 10 - .../lobby_host/start_battle_response.ex | 14 - .../lobby_host/update_bot_response.ex | 14 - .../lobby_host/updated_status_response.ex | 14 - .../responses/system/disconnect_response.ex | 12 - .../responses/system/error_response.ex | 12 - .../responses/system/ping_response.ex | 15 - .../responses/telemetry/event_response.ex | 12 - .../responses/telemetry/property_response.ex | 12 - .../user/updated_user_client_response.ex | 34 - .../tachyon_json_ws/socket/socket_lib.ex | 8 - .../tachyon_json_ws/tachyon_schema.ex | 44 - .../tachyon_json_ws/tachyon_socket.ex | 347 ----- lib/teiserver/protocols/tachyon_lib.ex | 116 -- lib/teiserver/protocols/tachyon_v1/auth_in.ex | 160 --- .../protocols/tachyon_v1/auth_out.ex | 101 -- .../protocols/tachyon_v1/client_in.ex | 28 - .../protocols/tachyon_v1/client_out.ex | 55 - .../protocols/tachyon_v1/communication_in.ex | 24 - .../protocols/tachyon_v1/communication_out.ex | 43 - .../protocols/tachyon_v1/config_in.ex | 110 -- .../protocols/tachyon_v1/config_out.ex | 33 - .../protocols/tachyon_v1/lobby_chat_out.ex | 23 - .../protocols/tachyon_v1/lobby_host_in.ex | 52 - .../protocols/tachyon_v1/lobby_host_out.ex | 33 - .../protocols/tachyon_v1/lobby_in.ex | 275 ---- .../protocols/tachyon_v1/lobby_out.ex | 482 ------- .../protocols/tachyon_v1/matchmaking_in.ex | 83 -- .../protocols/tachyon_v1/matchmaking_out.ex | 174 --- .../protocols/tachyon_v1/party_in.ex | 121 -- .../protocols/tachyon_v1/party_out.ex | 69 - .../protocols/tachyon_v1/system_in.ex | 87 -- .../protocols/tachyon_v1/system_out.ex | 96 -- lib/teiserver/protocols/tachyon_v1/tachyon.ex | 207 --- .../protocols/tachyon_v1/tachyon_in.ex | 149 -- .../protocols/tachyon_v1/tachyon_out.ex | 88 -- .../protocols/tachyon_v1/telemetry_in.ex | 18 - lib/teiserver/protocols/tachyon_v1/user_in.ex | 108 -- .../protocols/tachyon_v1/user_out.ex | 54 - lib/teiserver/servers/telemetry_server.ex | 18 - .../tcp/tachyon/tachyon_tcp_server.ex | 566 -------- .../controllers/api/hailstorm_controller.ex | 2 - lib/teiserver_web/endpoint.ex | 8 - lib/teiserver_web/router.ex | 8 - mix.exs | 1 + .../account/acceptFriendRequest/request.json | 12 - .../account/acceptFriendRequest/response.json | 50 - .../schema_v1/account/addFriend/request.json | 12 - .../schema_v1/account/addFriend/response.json | 50 - .../schema_v1/account/getFriends/request.json | 12 - .../account/getFriends/response.json | 189 --- .../account/getUserClients/request.json | 12 - .../account/getUserClients/response.json | 189 --- .../receivedFriendRequest/response.json | 50 - .../account/rejectFriendRequest/request.json | 12 - .../account/rejectFriendRequest/response.json | 50 - .../account/removeFriend/request.json | 12 - .../account/removeFriend/response.json | 50 - .../account/rescindFriendRequest/request.json | 12 - .../rescindFriendRequest/response.json | 50 - .../account/updateAccount/request.json | 12 - .../account/updateAccount/response.json | 50 - .../schema_v1/account/whoAmI/request.json | 12 - .../schema_v1/account/whoAmI/response.json | 50 - .../schema_v1/auth/getToken/request.json | 12 - .../schema_v1/auth/getToken/response.json | 220 --- .../schema_v1/auth/register/request.json | 12 - .../schema_v1/auth/register/response.json | 57 - .../schema_v1/clan/acceptInvite/request.json | 12 - .../schema_v1/clan/acceptInvite/response.json | 50 - .../schema_v1/clan/getClan/request.json | 12 - .../schema_v1/clan/getClan/response.json | 50 - .../schema_v1/clan/getClans/request.json | 12 - .../schema_v1/clan/getClans/response.json | 50 - .../schema_v1/clan/invite/request.json | 12 - .../schema_v1/clan/invite/response.json | 50 - .../schema_v1/clan/rejectInvite/request.json | 12 - .../schema_v1/clan/rejectInvite/response.json | 50 - .../schema_v1/clan/rescindInvite/request.json | 12 - .../clan/rescindInvite/response.json | 50 - .../getNotifications/request.json | 12 - .../getNotifications/response.json | 50 - .../receivedDirectMessage/response.json | 50 - .../sendDirectMessage/request.json | 12 - .../sendDirectMessage/response.json | 50 - .../schema_v1/config/getGame/request.json | 12 - .../schema_v1/config/getGame/response.json | 50 - .../config/getGameTypes/request.json | 12 - .../config/getGameTypes/response.json | 50 - .../config/getUserClient/request.json | 12 - .../config/getUserClient/response.json | 50 - .../config/getUserClientTypes/request.json | 12 - .../config/getUserClientTypes/response.json | 50 - .../schema_v1/config/setGame/response.json | 50 - .../config/setUserClient/response.json | 50 - .../tachyon/schema_v1/init/init/response.json | 55 - .../listener/getSubscriptions/request.json | 12 - .../listener/getSubscriptions/response.json | 50 - .../schema_v1/listener/subscribe/request.json | 12 - .../listener/subscribe/response.json | 50 - .../listener/unsubscribe/request.json | 12 - .../listener/unsubscribe/response.json | 50 - .../lobby/addUserClient/request.json | 12 - .../lobby/addUserClient/response.json | 50 - .../schema_v1/lobby/botAdded/request.json | 12 - .../schema_v1/lobby/botAdded/response.json | 50 - .../schema_v1/lobby/botRemoved/request.json | 12 - .../schema_v1/lobby/botRemoved/response.json | 50 - .../schema_v1/lobby/botUpdated/request.json | 12 - .../schema_v1/lobby/botUpdated/response.json | 50 - .../schema_v1/lobby/closed/request.json | 12 - .../schema_v1/lobby/closed/response.json | 50 - priv/tachyon/schema_v1/lobby/get/request.json | 12 - .../tachyon/schema_v1/lobby/get/response.json | 50 - .../schema_v1/lobby/getLobbies/request.json | 12 - .../schema_v1/lobby/getLobbies/response.json | 50 - .../tachyon/schema_v1/lobby/join/request.json | 12 - .../schema_v1/lobby/join/response.json | 50 - .../schema_v1/lobby/joined/request.json | 12 - .../schema_v1/lobby/joined/response.json | 50 - .../schema_v1/lobby/leave/request.json | 12 - .../schema_v1/lobby/leave/response.json | 50 - .../schema_v1/lobby/opened/request.json | 12 - .../schema_v1/lobby/opened/response.json | 50 - .../lobby/removeUserClient/request.json | 12 - .../lobby/removeUserClient/response.json | 50 - .../schema_v1/lobby/updateStatus/request.json | 12 - .../lobby/updateStatus/response.json | 50 - .../schema_v1/lobby/updated/request.json | 12 - .../schema_v1/lobby/updated/response.json | 50 - .../schema_v1/lobbyChat/announce/request.json | 12 - .../lobbyChat/announce/response.json | 50 - .../lobbyChat/announced/response.json | 50 - .../schema_v1/lobbyChat/said/response.json | 50 - .../schema_v1/lobbyChat/say/request.json | 12 - .../schema_v1/lobbyChat/say/response.json | 50 - .../schema_v1/lobbyHost/addBot/request.json | 12 - .../schema_v1/lobbyHost/addBot/response.json | 50 - .../schema_v1/lobbyHost/close/request.json | 12 - .../schema_v1/lobbyHost/close/response.json | 50 - .../schema_v1/lobbyHost/create/request.json | 12 - .../schema_v1/lobbyHost/create/response.json | 50 - .../lobbyHost/endBattle/request.json | 12 - .../lobbyHost/endBattle/response.json | 50 - .../lobbyHost/joinRequest/request.json | 12 - .../lobbyHost/joinRequest/response.json | 50 - .../lobbyHost/removeBot/request.json | 12 - .../lobbyHost/removeBot/response.json | 50 - .../lobbyHost/startBattle/request.json | 12 - .../lobbyHost/startBattle/response.json | 50 - .../lobbyHost/updateBot/request.json | 12 - .../lobbyHost/updateBot/response.json | 50 - .../lobbyHost/updatePlayerStatus/request.json | 12 - .../updatePlayerStatus/response.json | 50 - .../lobbyHost/updatedStatus/response.json | 50 - .../schema_v1/matchmaking/accept/request.json | 12 - .../matchmaking/accept/response.json | 50 - .../matchmaking/decline/request.json | 12 - .../matchmaking/decline/response.json | 50 - .../matchmaking/getJoinedQueues/request.json | 12 - .../matchmaking/getJoinedQueues/response.json | 50 - .../matchmaking/getQueue/request.json | 12 - .../matchmaking/getQueue/response.json | 50 - .../matchmaking/getQueues/request.json | 12 - .../matchmaking/getQueues/response.json | 50 - .../matchmaking/joinQueue/request.json | 12 - .../matchmaking/joinQueue/response.json | 50 - .../matchmaking/leaveAllQueues/request.json | 12 - .../matchmaking/leaveAllQueues/response.json | 50 - .../matchmaking/leaveQueue/request.json | 12 - .../matchmaking/leaveQueue/response.json | 50 - .../matchmaking/matchCancelled/response.json | 50 - .../matchmaking/matchReady/response.json | 50 - .../getReportingConfigs/request.json | 12 - .../getReportingConfigs/response.json | 50 - .../moderation/reportUserClient/request.json | 12 - .../moderation/reportUserClient/response.json | 50 - .../schema_v1/news/getNewsItems/request.json | 12 - .../schema_v1/news/getNewsItems/response.json | 50 - .../schema_v1/party/acceptInvite/request.json | 12 - .../party/acceptInvite/response.json | 50 - .../schema_v1/party/create/request.json | 12 - .../schema_v1/party/create/response.json | 50 - .../party/declineInvite/request.json | 12 - .../party/declineInvite/response.json | 50 - .../schema_v1/party/getParty/request.json | 12 - .../schema_v1/party/getParty/response.json | 50 - .../schema_v1/party/invite/request.json | 12 - .../schema_v1/party/invite/response.json | 50 - .../tachyon/schema_v1/party/kick/request.json | 12 - .../schema_v1/party/kick/response.json | 50 - .../party/rescindInvite/request.json | 12 - .../party/rescindInvite/response.json | 50 - .../schema_v1/party/seeMessage/response.json | 50 - .../schema_v1/party/sendMessage/request.json | 12 - .../schema_v1/party/sendMessage/response.json | 50 - .../schema_v1/party/updated/response.json | 50 - .../schema_v1/system/error/response.json | 50 - .../system/serverEvent/response.json | 50 - .../schema_v1/telemetry/event/request.json | 12 - .../schema_v1/telemetry/event/response.json | 50 - .../schema_v1/telemetry/property/request.json | 12 - .../telemetry/property/response.json | 50 - test/support/teiserver_test_lib.ex | 93 -- test/teiserver/account/accolade_bot_test.exs | 329 ----- test/teiserver/battle/lobby_cache_test.exs | 49 - test/teiserver/coordinator/automod_test.exs | 258 ---- .../coordinator/balance_server_test.exs | 651 --------- .../coordinator/consul_chat_test.exs | 121 -- .../coordinator/consul_commands_test.exs | 1212 ----------------- .../coordinator/coordinator_commands_test.exs | 243 ---- .../teiserver/coordinator/gatekeeper_test.exs | 137 -- .../coordinator/host_update_test.exs | 85 -- test/teiserver/coordinator/joining_test.exs | 151 -- test/teiserver/coordinator/lock_test.exs | 188 --- .../coordinator/match_monitor_server_test.exs | 136 -- test/teiserver/coordinator/memes_test.exs | 170 --- .../teiserver/coordinator/moderation_test.exs | 106 -- test/teiserver/coordinator/setup_test.exs | 72 - test/teiserver/coordinator/split_test.exs | 580 -------- .../admin/user_controller_test.exs | 83 -- .../controllers/api/spads_controller_test.exs | 78 -- test/teiserver_web/live/battle_live_test.exs | 72 +- 293 files changed, 6 insertions(+), 17810 deletions(-) delete mode 100644 documents/tachyon/auth.md delete mode 100644 documents/tachyon/clan.md delete mode 100644 documents/tachyon/client.md delete mode 100644 documents/tachyon/communication.md delete mode 100644 documents/tachyon/config.md delete mode 100644 documents/tachyon/listeners.md delete mode 100644 documents/tachyon/lobby.md delete mode 100644 documents/tachyon/lobby_chat.md delete mode 100644 documents/tachyon/lobby_host.md delete mode 100644 documents/tachyon/matchmaking.md delete mode 100644 documents/tachyon/news.md delete mode 100644 documents/tachyon/party.md delete mode 100644 documents/tachyon/readme.md delete mode 100644 documents/tachyon/server_comms.md delete mode 100644 documents/tachyon/system.md delete mode 100644 documents/tachyon/telemetry.md delete mode 100644 documents/tachyon/types.md delete mode 100644 documents/tachyon/user.md delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/cache.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/command_dispatch.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/converters.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/account/whoami_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/communication/send_direct_message_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/join_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/leave_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/list_lobbies_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/update_status_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_chat/say_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/create_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/respond_to_join_request_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/system/disconnect_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/system/force_error_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/system/no_command_error_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/system/ping_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/event_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/property_request.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/message_handlers/client_message_handlers.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_chat_message_handlers.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_host_message_handlers.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_update_message_handlers.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/account/whoami_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/communication/received_direct_message_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/communication/send_direct_message_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/add_user_client_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/closed_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/join_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/joined_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/leave_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/list_lobbies_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/received_join_request_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/remove_user_client_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby/update_status_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/said_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/say_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/add_bot_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/close_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/create_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/end_battle_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/join_request_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/remove_bot_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/respond_to_join_request_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/start_battle_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/update_bot_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/updated_status_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/system/disconnect_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/system/error_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/system/ping_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/event_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/property_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/responses/user/updated_user_client_response.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/socket/socket_lib.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/tachyon_schema.ex delete mode 100644 lib/teiserver/protocols/tachyon_json_ws/tachyon_socket.ex delete mode 100644 lib/teiserver/protocols/tachyon_lib.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/auth_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/auth_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/client_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/client_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/communication_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/communication_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/config_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/config_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/lobby_chat_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/lobby_host_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/lobby_host_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/lobby_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/lobby_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/matchmaking_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/matchmaking_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/party_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/party_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/system_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/system_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/tachyon.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/tachyon_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/tachyon_out.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/telemetry_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/user_in.ex delete mode 100644 lib/teiserver/protocols/tachyon_v1/user_out.ex delete mode 100644 lib/teiserver/tcp/tachyon/tachyon_tcp_server.ex delete mode 100644 priv/tachyon/schema_v1/account/acceptFriendRequest/request.json delete mode 100644 priv/tachyon/schema_v1/account/acceptFriendRequest/response.json delete mode 100644 priv/tachyon/schema_v1/account/addFriend/request.json delete mode 100644 priv/tachyon/schema_v1/account/addFriend/response.json delete mode 100644 priv/tachyon/schema_v1/account/getFriends/request.json delete mode 100644 priv/tachyon/schema_v1/account/getFriends/response.json delete mode 100644 priv/tachyon/schema_v1/account/getUserClients/request.json delete mode 100644 priv/tachyon/schema_v1/account/getUserClients/response.json delete mode 100644 priv/tachyon/schema_v1/account/receivedFriendRequest/response.json delete mode 100644 priv/tachyon/schema_v1/account/rejectFriendRequest/request.json delete mode 100644 priv/tachyon/schema_v1/account/rejectFriendRequest/response.json delete mode 100644 priv/tachyon/schema_v1/account/removeFriend/request.json delete mode 100644 priv/tachyon/schema_v1/account/removeFriend/response.json delete mode 100644 priv/tachyon/schema_v1/account/rescindFriendRequest/request.json delete mode 100644 priv/tachyon/schema_v1/account/rescindFriendRequest/response.json delete mode 100644 priv/tachyon/schema_v1/account/updateAccount/request.json delete mode 100644 priv/tachyon/schema_v1/account/updateAccount/response.json delete mode 100644 priv/tachyon/schema_v1/account/whoAmI/request.json delete mode 100644 priv/tachyon/schema_v1/account/whoAmI/response.json delete mode 100644 priv/tachyon/schema_v1/auth/getToken/request.json delete mode 100644 priv/tachyon/schema_v1/auth/getToken/response.json delete mode 100644 priv/tachyon/schema_v1/auth/register/request.json delete mode 100644 priv/tachyon/schema_v1/auth/register/response.json delete mode 100644 priv/tachyon/schema_v1/clan/acceptInvite/request.json delete mode 100644 priv/tachyon/schema_v1/clan/acceptInvite/response.json delete mode 100644 priv/tachyon/schema_v1/clan/getClan/request.json delete mode 100644 priv/tachyon/schema_v1/clan/getClan/response.json delete mode 100644 priv/tachyon/schema_v1/clan/getClans/request.json delete mode 100644 priv/tachyon/schema_v1/clan/getClans/response.json delete mode 100644 priv/tachyon/schema_v1/clan/invite/request.json delete mode 100644 priv/tachyon/schema_v1/clan/invite/response.json delete mode 100644 priv/tachyon/schema_v1/clan/rejectInvite/request.json delete mode 100644 priv/tachyon/schema_v1/clan/rejectInvite/response.json delete mode 100644 priv/tachyon/schema_v1/clan/rescindInvite/request.json delete mode 100644 priv/tachyon/schema_v1/clan/rescindInvite/response.json delete mode 100644 priv/tachyon/schema_v1/communication/getNotifications/request.json delete mode 100644 priv/tachyon/schema_v1/communication/getNotifications/response.json delete mode 100644 priv/tachyon/schema_v1/communication/receivedDirectMessage/response.json delete mode 100644 priv/tachyon/schema_v1/communication/sendDirectMessage/request.json delete mode 100644 priv/tachyon/schema_v1/communication/sendDirectMessage/response.json delete mode 100644 priv/tachyon/schema_v1/config/getGame/request.json delete mode 100644 priv/tachyon/schema_v1/config/getGame/response.json delete mode 100644 priv/tachyon/schema_v1/config/getGameTypes/request.json delete mode 100644 priv/tachyon/schema_v1/config/getGameTypes/response.json delete mode 100644 priv/tachyon/schema_v1/config/getUserClient/request.json delete mode 100644 priv/tachyon/schema_v1/config/getUserClient/response.json delete mode 100644 priv/tachyon/schema_v1/config/getUserClientTypes/request.json delete mode 100644 priv/tachyon/schema_v1/config/getUserClientTypes/response.json delete mode 100644 priv/tachyon/schema_v1/config/setGame/response.json delete mode 100644 priv/tachyon/schema_v1/config/setUserClient/response.json delete mode 100644 priv/tachyon/schema_v1/init/init/response.json delete mode 100644 priv/tachyon/schema_v1/listener/getSubscriptions/request.json delete mode 100644 priv/tachyon/schema_v1/listener/getSubscriptions/response.json delete mode 100644 priv/tachyon/schema_v1/listener/subscribe/request.json delete mode 100644 priv/tachyon/schema_v1/listener/subscribe/response.json delete mode 100644 priv/tachyon/schema_v1/listener/unsubscribe/request.json delete mode 100644 priv/tachyon/schema_v1/listener/unsubscribe/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/addUserClient/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/addUserClient/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/botAdded/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/botAdded/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/botRemoved/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/botRemoved/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/botUpdated/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/botUpdated/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/closed/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/closed/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/get/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/get/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/getLobbies/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/getLobbies/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/join/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/join/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/joined/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/joined/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/leave/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/leave/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/opened/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/opened/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/removeUserClient/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/removeUserClient/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/updateStatus/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/updateStatus/response.json delete mode 100644 priv/tachyon/schema_v1/lobby/updated/request.json delete mode 100644 priv/tachyon/schema_v1/lobby/updated/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyChat/announce/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyChat/announce/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyChat/announced/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyChat/said/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyChat/say/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyChat/say/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/addBot/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/addBot/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/close/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/close/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/create/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/create/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/endBattle/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/endBattle/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/joinRequest/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/joinRequest/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/removeBot/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/removeBot/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/startBattle/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/startBattle/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/updateBot/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/updateBot/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/request.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/response.json delete mode 100644 priv/tachyon/schema_v1/lobbyHost/updatedStatus/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/accept/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/accept/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/decline/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/decline/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/getJoinedQueues/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/getJoinedQueues/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/getQueue/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/getQueue/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/getQueues/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/getQueues/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/joinQueue/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/joinQueue/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/leaveAllQueues/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/leaveAllQueues/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/leaveQueue/request.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/leaveQueue/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/matchCancelled/response.json delete mode 100644 priv/tachyon/schema_v1/matchmaking/matchReady/response.json delete mode 100644 priv/tachyon/schema_v1/moderation/getReportingConfigs/request.json delete mode 100644 priv/tachyon/schema_v1/moderation/getReportingConfigs/response.json delete mode 100644 priv/tachyon/schema_v1/moderation/reportUserClient/request.json delete mode 100644 priv/tachyon/schema_v1/moderation/reportUserClient/response.json delete mode 100644 priv/tachyon/schema_v1/news/getNewsItems/request.json delete mode 100644 priv/tachyon/schema_v1/news/getNewsItems/response.json delete mode 100644 priv/tachyon/schema_v1/party/acceptInvite/request.json delete mode 100644 priv/tachyon/schema_v1/party/acceptInvite/response.json delete mode 100644 priv/tachyon/schema_v1/party/create/request.json delete mode 100644 priv/tachyon/schema_v1/party/create/response.json delete mode 100644 priv/tachyon/schema_v1/party/declineInvite/request.json delete mode 100644 priv/tachyon/schema_v1/party/declineInvite/response.json delete mode 100644 priv/tachyon/schema_v1/party/getParty/request.json delete mode 100644 priv/tachyon/schema_v1/party/getParty/response.json delete mode 100644 priv/tachyon/schema_v1/party/invite/request.json delete mode 100644 priv/tachyon/schema_v1/party/invite/response.json delete mode 100644 priv/tachyon/schema_v1/party/kick/request.json delete mode 100644 priv/tachyon/schema_v1/party/kick/response.json delete mode 100644 priv/tachyon/schema_v1/party/rescindInvite/request.json delete mode 100644 priv/tachyon/schema_v1/party/rescindInvite/response.json delete mode 100644 priv/tachyon/schema_v1/party/seeMessage/response.json delete mode 100644 priv/tachyon/schema_v1/party/sendMessage/request.json delete mode 100644 priv/tachyon/schema_v1/party/sendMessage/response.json delete mode 100644 priv/tachyon/schema_v1/party/updated/response.json delete mode 100644 priv/tachyon/schema_v1/system/error/response.json delete mode 100644 priv/tachyon/schema_v1/system/serverEvent/response.json delete mode 100644 priv/tachyon/schema_v1/telemetry/event/request.json delete mode 100644 priv/tachyon/schema_v1/telemetry/event/response.json delete mode 100644 priv/tachyon/schema_v1/telemetry/property/request.json delete mode 100644 priv/tachyon/schema_v1/telemetry/property/response.json delete mode 100644 test/teiserver/account/accolade_bot_test.exs delete mode 100644 test/teiserver/battle/lobby_cache_test.exs delete mode 100644 test/teiserver/coordinator/automod_test.exs delete mode 100644 test/teiserver/coordinator/balance_server_test.exs delete mode 100644 test/teiserver/coordinator/consul_chat_test.exs delete mode 100644 test/teiserver/coordinator/consul_commands_test.exs delete mode 100644 test/teiserver/coordinator/coordinator_commands_test.exs delete mode 100644 test/teiserver/coordinator/gatekeeper_test.exs delete mode 100644 test/teiserver/coordinator/host_update_test.exs delete mode 100644 test/teiserver/coordinator/joining_test.exs delete mode 100644 test/teiserver/coordinator/lock_test.exs delete mode 100644 test/teiserver/coordinator/match_monitor_server_test.exs delete mode 100644 test/teiserver/coordinator/memes_test.exs delete mode 100644 test/teiserver/coordinator/moderation_test.exs delete mode 100644 test/teiserver/coordinator/setup_test.exs delete mode 100644 test/teiserver/coordinator/split_test.exs diff --git a/config/config.exs b/config/config.exs index a3975bb12..7fbf4800d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -46,15 +46,13 @@ config :esbuild, config :teiserver, Teiserver, ports: [ tcp: 8200, - tls: 8201, - tachyon: 8202 + tls: 8201 ], website: [ url: "mywebsite.com" ], enable_benchmark: false, enable_hooks: true, - tachyon_schema_path: "priv/tachyon/schema_v1/*/*/*.json", # Heatbeat interval is ms heartbeat_interval: 30_000, @@ -67,7 +65,6 @@ config :teiserver, Teiserver, main_website: "https://site.com/", discord: nil, default_spring_protocol: Teiserver.Protocols.Spring, - default_tachyon_protocol: Teiserver.Protocols.Tachyon.V1.Tachyon, github_repo: "https://github.com/beyond-all-reason/teiserver", enable_discord_bridge: true, enable_coordinator_mode: true, diff --git a/config/runtime.exs b/config/runtime.exs index 0c64106de..0d9cfcc8b 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -55,10 +55,7 @@ if config_env() == :prod do enable_discord_bridge: enable_discord_bridge, ports: [ tcp: Teiserver.ConfigHelpers.get_env("TEI_SPRING_TCP_PORT", 8200, :int), - tls: Teiserver.ConfigHelpers.get_env("TEI_SPRING_TLS_PORT", 8201, :int), - # this can likely be deprecated and removed. It's for an old version - # of tachyon running on another TLS socket - tachyon: Teiserver.ConfigHelpers.get_env("TEI_TACHYON_TLS_PORT", 8202, :int) + tls: Teiserver.ConfigHelpers.get_env("TEI_SPRING_TLS_PORT", 8201, :int) ], certs: certificates, website: [ diff --git a/config/test.exs b/config/test.exs index fe717431f..677f3abcc 100644 --- a/config/test.exs +++ b/config/test.exs @@ -23,8 +23,7 @@ config :teiserver, Teiserver, ], ports: [ tcp: 9200, - tls: 9201, - tachyon: 9202 + tls: 9201 ], test_mode: true, enable_hooks: false, diff --git a/documents/tachyon/auth.md b/documents/tachyon/auth.md deleted file mode 100644 index fc452163d..000000000 --- a/documents/tachyon/auth.md +++ /dev/null @@ -1,178 +0,0 @@ -### `c.auth.get_token` -Given the correct email and password combination the server will send back a token that can be used to login as that user. This command must be performed over a secure connection, if it is attempted over an insecure connection the server will send back an error. If the password and email do not match a failure result is returned. - -* email :: string -* password :: string - -#### Success response -* token :: string - -#### Example input/output -```json -{ - "cmd": "c.auth.get_token", - "email": "email@email.com", - "password": "*********" -} - -{ - "cmd": "s.auth.get_token", - "result": "success", - "token": "long-string-of-digits-here" -} - -{ - "cmd": "s.auth.get_token", - "result": "failure", - "reason": "reason for failure" -} -``` - -### `c.auth.login` -Performs user authentication via a token obtained from `c.auth.token`. -* token :: string -* lobby_name :: string -* lobby_version :: string - -#### Success response -* user :: User - -#### Example input/output -```json -{ - "cmd": "c.auth.login", - "lobby_name": "Bar Lobby", - "lobby_version": "1.3.2", - "lobby_hash": "1234567890", - "token": "long-string-of-digits-here" -} - -{ - "cmd": "s.auth.login", - "result": "success", - "user": User -} - -{ - "cmd": "s.auth.login", - "result": "unverified", - "agreement": "Multiline\nText\nBlob" -} - -{ - "cmd": "s.auth.login", - "result": "failure", - "reason": "Invalid token" -} -``` - -### `c.auth.verify` -Confirms the accuracy of the user email address. Once successful the user will be marked as verified and the user logged in. -* token :: string -* verification_code :: string - -#### Success response -* user :: User - -#### Example input/output -```json -{ - "cmd": "c.auth.verify", - "token": "long-string-of-digits-here", - "code": "123456" -} - -{ - "cmd": "s.auth.verify", - "result": "success", - "user": User -} - -{ - "cmd": "s.auth.verify", - "result": "failure", - "reason": "bad code" -} -``` - -## `c.auth.disconnect` - - -#### Success response -The connection will be terminated, there will be no response. - -#### Example input/output -```json -{ - "cmd": "c.auth.disconnect" -} -``` - -## `c.auth.register` -Requests the creation of a new user account on the server -* username :: string -* email :: email address -* password :: string (this will be stored in a hashe - -#### Success response -You will receive a standard success response, if it fails you will receive a failure response. Once registered you can attempt to login though the server may require you to validate the account before the login can be successful. - -#### Example input/output -```json -{ - "cmd": "c.auth.register", - "username": "new_user_101", - "email": "new_user@101.example" - "password": "my_password" -} - -{ - "cmd": "s.auth.register", - "result": "success" -} - -{ - "cmd": "s.auth.register", - "result": "failure", - "reason": "email already exists" -} -``` - -## TODO: `c.auth.migrate` -For users who do not have an email associated with their account (only possible when registering an account with the legacy protocol). Users will need to do this in order to login via Tachyon. -* username :: string -* password :: string -* email :: email address - -#### Example input/output -```json -{ - "cmd": "c.auth.migrate", - "username": "existing_user", - "password": "my_password", - "desired_email": "existing_user@101.example" -} - -{ - "cmd": "s.auth.migrate", - "result": "success" -} - -{ - "cmd": "s.auth.migrate", - "result": "failure", - "reason": "A user with that email address already exists" -} - -{ - "cmd": "s.auth.migrate", - "result": "failure", - "reason": "User does not exist" -} - -{ - "cmd": "s.auth.migrate", - "result": "failure", - "reason": "Invalid password" -} -``` diff --git a/documents/tachyon/clan.md b/documents/tachyon/clan.md deleted file mode 100644 index 7e7683392..000000000 --- a/documents/tachyon/clan.md +++ /dev/null @@ -1,8 +0,0 @@ -#### Data -- List clans -- List clan members - -#### User -- Invite -- Respond to invite -- Set as primary diff --git a/documents/tachyon/client.md b/documents/tachyon/client.md deleted file mode 100644 index ed00d4db7..000000000 --- a/documents/tachyon/client.md +++ /dev/null @@ -1,79 +0,0 @@ -### c.client.list_clients_from_ids -Given a list of ids, return information about the relevant clients - -#### Arguments -`id_list` - list (User.id) - -#### Response -* clients :: List (Client) - -#### Example input/output -```json -{ - "cmd": "c.client.list_clients_from_ids", - "id_list": [1, 2, 3] -} - -{ - "cmd": "s.client.client_list", - "clients": [ - Client, - Client, - Client - ] -} -``` - - -### s.client.connected -```json -{ - "cmd": "s.client.connected", - "userid": 123 -} -``` - -### s.client.disconnected -```json -{ - "cmd": "s.client.disconnected", - "userid": 123 -} -``` - -### s.client.added_to_party -```json -{ - "cmd": "s.client.added_to_party", - "userid": 123, - "party_id": "abc" -} -``` - -### s.client.left_party -```json -{ - "cmd": "s.client.left_party", - "userid": 123, - "party_id": "abc" -} -``` - - -### s.client.added_to_lobby -```json -{ - "cmd": "s.client.added_to_lobby", - "userid": 123, - "lobby_id": "abc" -} -``` - -### s.client.left_lobby -```json -{ - "cmd": "s.client.left_lobby", - "userid": 123, - "lobby_id": "abc" -} -``` diff --git a/documents/tachyon/communication.md b/documents/tachyon/communication.md deleted file mode 100644 index 3df0e158a..000000000 --- a/documents/tachyon/communication.md +++ /dev/null @@ -1,147 +0,0 @@ -### TODO: `c.communication.join_room` -* room_name :: string - -#### Success response -* result :: "success" - -#### Failure response -* result :: "failure" -* reason :: string - -#### Example input/output -```json -{ - "cmd": "c.communication.join_room", - "room_name": "main" -} - -{ - "cmd": "s.communication.join_room", - "result": "success" -} - - -{ - "cmd": "c.communication.join_room", - "room_name": "private_room" -} - -{ - "cmd": "s.communication.join_room", - "result": "failure", - "reason": "Inadequate permissions" -} -``` - -### TODO: `c.communication.leave_room` -* room_name :: string - -#### Success response -Success is assumed, no response is sent - -#### Example input/output -```json -{ - "cmd": "c.communication.leave_room", - "room_name": "main" -} -``` - -### TODO: `c.communication.list_members` -* room_name :: string - -#### Success response -* member_ids :: List (userid) - -#### Example input/output -```json -{ - "cmd": "c.communication.list_members", - "room_name": "main" -} - -{ - "cmd": "s.communication.list_members", - "member_ids": [1, 2, 3] -} -``` - - -### TODO: `c.communication.room_message` -* room_name :: string -* message :: string - -#### Success response -This command has no response expected. Though you should receive a `s.communication.room_message` from yourself (as will everybody else in the room). - -#### Example input/output -```json -{ - "cmd": "c.communication.room_message", - "room_name": "main", - "message": "hello room!" -} -``` - -### TODO: `s.communication.room_message` -Sent when a new message is sent to a room. - -* room_name :: string -* message :: string -* sender_id :: userid - -#### Example input/output -```json -{ - "cmd": "s.communication.room_message", - "room_name": "main", - "message": "hello room!", - "sender_id": 123 -} -``` - -### TODO: `c.communication.send_direct_message` -* recipient_id :: userid -* message :: string - -#### Success response -* result :: "success" - -#### Failure response -* result :: "failure" -* reason :: string - -#### Example input/output -```json -{ - "cmd": "c.communication.send_direct_message", - "recipient_id": 789, - "message": "hello person!" -} - -{ - "cmd": "s.communication.send_direct_message", - "result": "success" -} - -{ - "cmd": "s.communication.send_direct_message", - "result": "failure", - "reason": "muted" -} -``` - -### TODO: `s.communication.received_direct_message` -* sender_id :: userid -* message :: string - -#### Example -```json -{ - "cmd": "s.communication.received_direct_message", - "sender_id": 123, - "message": "hello person!" -} -``` - - diff --git a/documents/tachyon/config.md b/documents/tachyon/config.md deleted file mode 100644 index bc40c1a75..000000000 --- a/documents/tachyon/config.md +++ /dev/null @@ -1,89 +0,0 @@ -## -A set of commands for getting/setting configs. Not to be confused with user_configs. - -## Game configs -Game configs are a key-value store with no enforced structure. You can add keys as you wish, you can update keys to any type. Keys must be strings though values can be strings, integers, booleans, lists or even maps. - -Note this is not designed to be a large data store, please don't store large blobs of data in it. - -### `c.config.game_set` -```json -{ - "cmd": "c.config.game_set", - "configs": { - "key1": "value1", - "key2": "123", - } -} -``` - -### `c.config.game_get` -If a game config hasn't been set or is nil it will be absent from the results. -```json -{ - "cmd": "c.config.game_get", - "keys": ["key1", "key2", "missing_key"] -} - -{ - "cmd": "s.config.game_get", - "configs": { - "key1": "value1", - "key2": "123", - } -} -``` - -### `c.config.game_delete` -```json -{ - "cmd": "c.config.game_set", - "keys": ["value1", "123"] -} -``` - -## User configs -User configs are tied to the Teiserver structured configs that can be accessed on the site itself. These are constrained by data type (though will where possible convert inputs to that data type) and come with defaults. - -### `c.config.list_user_types` -Lists the types of configs available to get/set. -```json -{ - "cmd": "c.config.list_user_types" -} - -{ - "cmd": "s.config.list_user_types", - "configs": [ - UserConfigType, - UserConfigType, - ] -} -``` - -### `c.config.user_set` -```json -{ - "cmd": "c.config.user_set", - "configs": { - "key1": "value1", - "key2": "123", - } -} -``` - -### `c.config.user_get` -```json -{ - "cmd": "c.config.user_get", - "keys": ["key1", "key2"] -} - -{ - "cmd": "s.config.user_get", - "configs": { - "key1": "value1", - "key2": "123", - } -} -``` diff --git a/documents/tachyon/listeners.md b/documents/tachyon/listeners.md deleted file mode 100644 index 1a11800cc..000000000 --- a/documents/tachyon/listeners.md +++ /dev/null @@ -1,17 +0,0 @@ -## Listeners -Tachyon uses Listeners to allow clients to subscribe to certain update channels. When you login you will be subscribed to a user update channel for that user, meaning if a server change happens to your account you'd receive a message (even if you were the one that prompted the change). Some commands will allow you to manually subscribe/unsubscribe from various listeners. It is not expected you will need these as part of standard lobby use but could be very useful for certain automation purposes. - -### Defaults -- You are subscribed to your own `user` channel (`teiserver_client_messages:#{userid}`) -- You are subscribed to your own `private-chat` channel () - -### User -- Can subscribe to your friends to see changes to their users - -### Battle -- Joining/Leaving a battle will sub/unsub you from the battle - -### Chat room -- Joining/Leaving a chat room will sub/unsub you from the room -- You subscribe to messages by default - diff --git a/documents/tachyon/lobby.md b/documents/tachyon/lobby.md deleted file mode 100644 index 253da5aca..000000000 --- a/documents/tachyon/lobby.md +++ /dev/null @@ -1,372 +0,0 @@ -## Showing -### s.lobby.opened -Sent by the server after watching all lobbies via `c.system.watch`. -```json -{ - "cmd": "s.lobby.opened", - "lobby": lobby -} -``` - - -### s.lobby.closed -Sent by the server after watching all lobbies via `c.system.watch`. -```json -{ - "cmd": "s.lobby.closed", - "lobby_id": integer -} -``` - -### c.lobby.query -* query :: Query -* fields :: List (optional) - -`fields` lists the additional items to return as part of each lobby. See `c.lobby.get` for more information on which fields can be included. By default the list will be a single item of `lobby`. - -#### Queryable fields -- `locked` - Boolean -- `passworded` - Boolean -- `in_progress` - Boolean -- `id_list` - List (Lobby ID) - -##### Planned items to add -- `min_player_count` - Integer, a count of the number of players in the lobby -- `max_player_count` - Integer, a count of the number of players in the lobby -- `spectator_count` - Integer, a count of the number of spectators in the lobby -- `member_count` - Integer, a count of the number of players and spectators in the lobby - -#### Success response -* lobbies :: List (Battle) - -#### Example input/output -```json -{ - "cmd": "c.lobby.query", - "fields": [], - "query": { - "locked": false - } -} - -{ - "cmd": "s.lobby.query", - "lobbies": [ - Battle, - Battle, - Battle - ] -} -``` - - -### c.lobby.get -Gets various properties from a lobby based on the command. - -Allowed keys: -- lobby -- modoptions -- bots -- players (a list of all player clients) -- member_list (contains a list of all the member clients) - -```json -{ - "cmd": "c.lobby.get", - "lobby_id": 123, - "keys": ["lobby", "modoptions", "bots"] -} - -{ - "cmd": "s.lobby.get", - "lobby_id": 123, - "lobby": {}, - "bots": {}, - "modoptions": {}, -} -``` - -## Interacting -### c.lobby.join -Requests to join the lobby, the host will be sent a message asking if the person can join or not. Based on that an accept/reject is sent. If there is a failure to join then it means the host wasn't even consulted as the joiner didn't qualify (e.g. didn't supply the password). -**Stage 1** -```json -{ - "cmd": "c.lobby.join", - "lobby_id": 123, - "password": "******" // Optional -} - -// Response -{ - "cmd": "s.lobby.join", - "result": "waiting_for_host" -} - -{ - "cmd": "s.lobby.join", - "result": "failure", - "reason": "Reason for failure" -} -``` - -**Stage 2** - sent to the lobby host -```json -// Host approves/rejects the joiner -// this is what the lobby host sees -{ - "cmd": "s.lobby_host.request_to_join", - "userid": 456 -} - -// This is how the lobby host replies to the server -{ - "cmd": "c.lobby_host.respond_to_join_request", - "userid": 456, - "response": "approve" -} - -{ - "cmd": "c.lobby_host.respond_to_join_request", - "userid": 456, - "response": "reject", - "reason": "Reason for rejection" -} -``` - -**Stage 3** -```json -// Server sends the response to the would-be player -// Approval -{ - "cmd": "s.lobby.join_response", - "script_password": "123456789", - "result": "approve", - "lobby": Lobby, - "modoptions": [modoptions], - "bots": [], - "player_list": [userid], - "member_list": [userid], -} - -// Rejection -{ - "cmd": "s.lobby.join_response", - "lobbyid": 123, - "result": "reject", - "reason": "Reason for rejection" -} -``` - -### `c.lobby.force_join` -Used when the server moves you to a lobby. It will move you out of your existing lobby (if in one) and into the lobby in the message. -```json -{ - "cmd": "s.lobby.join_response", - "script_password": "123456789", - "result": "approve", - "lobby": Lobby, - "modoptions": [modoptions], - "bots": [], - "player_list": [userid], - "member_list": [userid], -} -``` - -### c.lobby.leave -No server response. -```json -{ - "cmd": "c.lobby.leave" -} -``` - -### TODO: c.lobby.send_invite -Sends an invite to a user to them to join the same lobby as yourself. They will still have to go through the same approval process as any other join_lobby command. No response from server. -```json -{ - "cmd": "c.lobby.send_invite", - "userid": 123, - "lobby_id": 321, - "message": "Please come play with me" // Optional? -} -``` - - -### TODO: s.lobby.invite_to_lobby -The message seen by a player being invited to a lobby. -```json -{ - "cmd": "s.lobby.invite_to_lobby", - "from_userid": 111, - "lobby_id": 321, - "message": "Please come play with me" // Optional?, -} -``` - -### TODO: c.lobby.respond_to_invite -Respond to an invite. This is equivalent to sending the join_lobby command listed above, the key difference it will circumvent certain locks (e.g. passwords). -```json -{ - "cmd": "c.lobby.respond_to_invite", - "lobby_id": 321, - "accept": true, -} - -{ - "cmd": "c.lobby.respond_to_invite", - "lobby_id": 321, - "accept": false, -} -``` - -### TODO: c.lobby.update_status -Sent by a client to inform the server their status is updated. Below are the fields you can update as part of the `client` object you send with the message: - -* `status`: String -- one of: ready, unready, afk, in-game -* `player_id`: integer -- In spring this would be `team_number` -* `team_id`: integer -- In spring this would be `ally_team_number` -* `team_color`: colour -* `player`: boolean -* `sync`: list(String) -- A list of things not yet sync'd, e.g. map, engine -* `faction`: string - -```json -{ - "cmd": "c.lobby.update_status", - "client": { - "status": "ready", - "player_id": 3, - "team_id": 1, - "team_color": "#AA55AA", - "player": true, - "sync": ["map", "game"], - "faction": "cortex" - } -} -``` - -### s.lobby.update_values -Sent by the server to inform of a change in one or more lobby_data values. -```json -{ - "cmd": "c.lobby.update_values", - "lobby_id": 123, - "new_values": { - "map_name": "Not DSDR" - } -} - -``` - -### s.lobby.add_user -Sent by the server to inform of a new player joining the lobby. -```json -{ - "cmd": "s.lobby.add_user", - "lobby_id": lobby_id, - "joiner_id": user_id, - "user": User, - "client": Client -} -``` - -### TODO: s.lobby.received_lobby_direct_announce -Sent by the server to inform of an announcement made in the room - -### s.lobby.updated_queue -Sent by the server when the queue of players waiting to join changes -```json -{ - "cmd": "s.lobby.updated_queue", - "lobby_id": 650, - "queue": [4239, 24215, 2183, 25341, 180, 36798, 7102, 14643, 22882] -} -``` - -## Bots -The responses listed here are the messages which will be sent when any bot is added, updated or removed. The bot commands do not have a success/failure response. - -### c.lobby.add_bot -Used to add a bot to the lobby. Once added only the host and owner can alter it. - -```json -{ - "cmd": "c.lobby.add_bot", - "name": "MyAmazingBot", - "ai_dll": "MyBotDLL", - "status": { - "team_colour": "42537", - "player_number": 8, - "team_number": 2, - "side": 1 - } -} - -{ - "cmd": "s.lobby.add_bot", - "bot": { - "ai_dll": "MyBotDLL", - "handicap": 0, - "name": "MyAmazingBot", - "owner_id": 123, - "owner_name": "MyNameHere", - "player": true, - "player_number": 8, - "ready": true, - "side": 1, - "sync": {"engine": 1, "game": 1, "map": 1}, - "team_colour": "42537", - "team_number": 2 - } -} -``` - -### c.lobby.update_bot -```json -{ - "cmd": "c.lobby.update_bot", - "name": "MyAmazingBot", - "status": { - "team_colour": "123445", - "player_number": 6, - "team_number": 1, - "side": 1, - } -} - -{ - "cmd": "s.lobby.update_bot", - "bot": { - "ai_dll": "MyBotDLL", - "handicap": 0, - "name": "MyAmazingBot", - "owner_id": 123, - "owner_name": "MyNameHere", - "player": true, - "player_number": 6, - "ready": true, - "side": 1, - "sync": {"engine": 1, "game": 1, "map": 1}, - "team_colour": "123445", - "team_number": 1 - } -} -``` - -### c.lobby.remove_bot -```json -{ - "cmd": "c.lobby.remove_bot", - "name": "MyAmazingBot" -} - -{ - "cmd": "s.lobby.remove_bot", - "bot_name": "BotNumeroUno" -} -``` - -## TODO: Telemetry -- Mid-battle updates? - diff --git a/documents/tachyon/lobby_chat.md b/documents/tachyon/lobby_chat.md deleted file mode 100644 index 9cd152da2..000000000 --- a/documents/tachyon/lobby_chat.md +++ /dev/null @@ -1,8 +0,0 @@ - - -### TODO: `c.lobby.say` -### TODO: `s.lobby.say` - -### TODO: `c.lobby.announce` -- Previously sayex -### TODO: `s.lobby.announce` - diff --git a/documents/tachyon/lobby_host.md b/documents/tachyon/lobby_host.md deleted file mode 100644 index d516c510a..000000000 --- a/documents/tachyon/lobby_host.md +++ /dev/null @@ -1,91 +0,0 @@ -## Creation/Management -### `c.lobby_host.create` -* battle :: - * name :: string - * nattype :: string (none | holepunch | fixed) - * password :: string, default: nil - * port :: integer - * game_hash :: string - * map_hash :: string - * map_name :: string - * game_name :: string - * engine_name :: string - * engine_version :: string - * ip :: string - * settings :: map - -#### Success response -* battle :: Battle - -#### Example input/output -```json -{ - "cmd": "c.lobby_host.create", - "battle": { - "name": "EU 01 - 123", - "nattype": "none", - "password": "password2", - "port": 1234, - "game_hash": "string_of_characters", - "map_hash": "string_of_characters", - "map_name": "koom valley", - "game_name": "BAR", - "engine_name": "spring-105", - "engine_version": "105.1.2.3", - "ip": "127.0.0.1", - "settings": { - "max_players": 12 - } - } -} - -{ - "cmd": "s.lobby_host.query", - "result": "success", - "battle": Battle -} - -{ - "cmd": "s.lobby_host.query", - "result": "falure", - "reason": "Permission denied" -} -``` - -### `c.lobby_host.respond_to_join_request` -The response to a `s.lobby.user_requests_to_join` message informing the server if the request has been accepted or rejected. No server response. -```json -{ - "cmd": "c.lobby_host.respond_to_join_request", - "response": "accept", - "userid": 123 -} - -{ - "cmd": "c.lobby_host.respond_to_join_request", - "response": "reject", - "reason": "reason given", - "userid": 123 -} -``` - -### TODO: `c.lobby_host.update_status` -Update the status of a player - -### TODO: `s.lobby_host.updated_status` -Tells you a player has had their status updated (by themselves, you or the server) - - -### TODO: `c.lobby_host.update_host_state` -### TODO: `s.lobby_host.updated_host_state` - -### TODO: `c.lobby_host.add_bot` -### TODO: `c.lobby_host.update_bot` -### TODO: `c.lobby_host.remove_bot` - - - -### TODO: `c.lobby_host.start` -### TODO: `c.lobby_host.end` -### TODO: `c.lobby_host.close` - diff --git a/documents/tachyon/matchmaking.md b/documents/tachyon/matchmaking.md deleted file mode 100644 index e19028553..000000000 --- a/documents/tachyon/matchmaking.md +++ /dev/null @@ -1,126 +0,0 @@ -## Showing -### `c.matchmaking.query` -* query :: Query - -#### Queryable fields --- None yet - -#### Success response -* queue_list :: List (Queue) - -#### Example input/output -```json -{ - "cmd": "c.matchmaking.query", - "query": Query -} - -{ - "cmd": "s.matchmaking.query", - "matchmaking_list": [ - Queue, - Queue, - Queue - ] -} -``` - -### TODO: `c.matchmaking.list_my_queues` -Operates the same way as the queue query but with a preset set of filters, only returning queues you are currently a part of. - -### `c.matchmaking.get_queue_info` -### Result -* wait_time: The amount of time most players are waiting for a game (in seconds), exact method of calculation may vary -* player_count: The number of players currently in the queue - -#### Example input/output -```json -{ - "cmd": "c.matchmaking.get_queue_info", - "queue_id": 123 -} - -{ - "cmd": "s.matchmaking.queue_info", - "queue": { - "queue_id": 123, - "name": "Best queue name in the world", - "mean_wait_time": 33, - "group_count": 2 - } -} -``` - -### TODO: `c.matchmaking.join_queue` -Tells the server to add the player to the MM queue. A player can be part of multiple queues at the same time (provided they and their party meet all criteria of the queues such as party size). - -```json -%{ - "cmd": "c.matchmaking.join_queue", - "queue_id": 123 -} -``` - -### TODO: `c.matchmaking.leave_queue` -Tells the server to remove the player from the specified MM queue. No response expected. - -```json -%{ - "cmd": "c.matchmaking.leave_queue", - "queue_id": 123 -} -``` - -### TODO: `c.matchmaking.leave_all_queues` -Tells the server to remove the player from all MM queues. No response selected. -```json -%{ - "cmd": "c.matchmaking.leave_all_queues" -} -``` - -### TODO: `s.matchmaking.match_ready` -```json -{ - "cmd": "s.matchmaking.match_ready", - "match_id": "match-id-string", - "queue_id": 123 -} -``` -When a match is made all players are sent this command. They should display an accept/decline dialog to the user and submit the response to the server accordingly. - -If all players ready up the game is created. If any players fail to ready up in the time frame or decline those players are removed from all matchmaking queues (they can rejoin though a timeout could be applied) and the players that did ready up are placed back in the queue in their previous positions (the readyup state is removed). - -### TODO: `c.matchmaking.accept` -Tells the server the player accepts the match. The match_id needs to be included in the response. -```json -{ - "cmd": "s.matchmaking.match_ready", - "match_id": "match-id-string" -} -``` - -### TODO: `c.matchmaking.decline` -Tells the server the player is not ready to participate in the MM game. This will result in the player being removed from all MM queues as if they'd sent `c.matchmaking.leave_all_queues`. - -### TODO: `s.matchmaking.match_declined` -Sent when you have either declined the match or have failed to accept within the required timeframe. As part of this you will have been removed from all queues so will need to rejoin them. -```json -{ - "cmd": "s.matchmaking.match_declined", - "match_id": "match-id-string", - "queue_id": 123 -} -``` - -### TODO: `s.matchmaking.match_cancelled` -Sent when one or more players have declined or failed to accept in time. You will be re-added to all queues you were in and at the search range you were in when you left. -```json -{ - "cmd": "s.matchmaking.match_cancelled", - "match_id": "match-id-string", - "queue_id": 123 -} -``` - - diff --git a/documents/tachyon/news.md b/documents/tachyon/news.md deleted file mode 100644 index 0b4766ae5..000000000 --- a/documents/tachyon/news.md +++ /dev/null @@ -1,27 +0,0 @@ -## Blog -### `c.news.get_latest_game_news` -Requires a category name and will return the latest -TODO: Add cache invalidation without refresh-on-touch -TODO: Identify if using a cache for categories and a cache for posts is better than a combined one using the :category_name filter in post_lib.ex - -#### Success response -* blog_post :: BlogPost - -If the blog post does not exist or the category does not exist then you will receive a null response for the `blog_post` key. - -```json -{ - "cmd": "c.news.get_latest_game_news", - "category": "Game updates" -} - -{ - "cmd": "s.news.get_latest_game_news", - "blog_post": BlogPost -} - -{ - "cmd": "s.news.get_latest_game_news", - "blog_post": null -} -``` \ No newline at end of file diff --git a/documents/tachyon/party.md b/documents/tachyon/party.md deleted file mode 100644 index bde9d9ef7..000000000 --- a/documents/tachyon/party.md +++ /dev/null @@ -1,219 +0,0 @@ -### `c.party.create` -Creates a new party, if you are part of an existing party it will remove you from that party. You will be the leader of the new party and the sole member. - -#### Success response -* party :: Party - -#### Example input/output -```json -{ - "cmd": "c.party.create" -} - -{ - "cmd": "s.party.added_to", - "party": { - "id": "1d5366a6-f55d-11ec-b427-f02f74dbae33", - "leader": 123, - "members": [123], - "pending_invites": [] - } -} -``` - -### `c.party.info` -Returns info about a given party. If you are not a member of the party then pending invites will always be missing. If the party does not exist, it will return null for the party. - -#### Example input/output -```json -{ - "cmd": "c.party.info", - "party_id": "1d5366a6-f55d-11ec-b427-f02f74dbae33" -} - -{ - "cmd": "s.party.info", - "party": { - "id": "1d5366a6-f55d-11ec-b427-f02f74dbae33", - "leader": 123, - "members": [123], - "pending_invites": [] - } -} - -{ - "cmd": "s.party.info", - "party": null -} -``` - -### `s.party.updated` -Sends a new party state. Fires upon any updates to the party such as change of invites, membership or leadership. It will contain a the changed values within the party. If a value is absent it means it was not changed. - -#### Example output -```json -{ - "cmd": "s.party.updated", - "party_id": "1d5366a6-f55d-11ec-b427-f02f74dbae33", - "new_values": { - "leader": 123, - "members": [123, 124], - "pending_invites": [125] - } -} -``` - -### `c.party.invite` -Invites a user to the party; if successful you will get a `s.party.updated` sent as a response as the party state updates. - -#### Example input -```json -{ - "cmd": "c.party.invite", - "userid": 123 -} -``` - -### `s.party.invite` -Server message telling a user they have been invited to a party, it will contain full party info (including pending invites) and the user who invited you. Your ID should be included in the `pending_invites` key. - -#### Example input -```json -{ - "cmd": "s.party.invite", - "party": { - "id": "1d5366a6-f55d-11ec-b427-f02f74dbae33", - "leader": 123, - "members": [123, 124], - "pending_invites": [125] - } -} -``` - -### `c.party.accept` -Accept an invite to a party, this will result in you being added to the party as a member and leaving your existing party if you are a member of one. As the party state will change you will be sent a `s.party.updated` response. If unsuccessful you will receive a failure response. - -#### Example input/output -```json -{ - "cmd": "c.party.accept", - "party_id": "1d5366a6-f55d-11ec-b427-f02f74dbae33" -} - -// Success -{ - "cmd": "s.party.added_to", - "party": Party -} - -// Failure -{ - "cmd": "s.party.accept", - "party_id": "1d5366a6-f55d-11ec-b427-f02f74dbae33", - "result": "failure" -} -``` - -### `s.party.added_to` -Sent when you are added to a party. -```json -{ - "cmd": "s.party.added_to", - "party": Party -} -``` - -### `c.party.decline` -Cancel the invitation to the party. - -#### Example input -```json -{ - "cmd": "c.party.cancel_invite", - "userid": 123 -} -``` - -### `c.party.decline` -Reject the invitation to the party, result in you being removed from the party invite list. - -#### Example input -```json -{ - "cmd": "c.party.decline", - "party_id": "1d5366a6-f55d-11ec-b427-f02f74dbae33" -} -``` - -### `c.party.kick` -Kicks a member of the party out, only useable by the party leader. If successful you will receive a `s.party.kicked` message (along with everybody else in the party). - -#### Example input/output -```json -{ - "cmd": "c.party.kick", - "userid": 124 -} - -{ - "cmd": "s.party.kicked", - "user_id": 124, - "kicked_by": 123 -} -``` - -### `s.party.kicked` -Sent when a member of the party is kicked, this is sent in place of the normal `s.party.updated` which would be sent on party change. - -#### Example output -```json -{ - "cmd": "s.party.kicked", - "user_id": 124, - "kicked_by": 123 -} -``` - -### `c.party.new_leader` -Used by the leader of the party to assign a new leader. Does not change the party membership but will prompt a `s.party.updated` message. - -#### Example input -```json -{ - "cmd": "c.party.new_leader", - "user_id": 124 -} -``` - -### `c.party.leave` -Remove yourself from the party. If you are the leader of the party it will assign a the longest serving member of the party to be the new leader. Remaining party members will receive a `s.party.updated` message. - -#### Example input -```json -{ - "cmd": "c.party.leave" -} -``` - -### `c.party.message` -Send a message to the party chat. - -#### Example input -```json -{ - "cmd": "c.party.message", - "message": "My fancy message here" -} -``` - -### `s.party.message` -Server informing you of a message in the party chat. - -#### Example output -```json -{ - "cmd": "s.party.message", - "sender_id": 124, - "message": "My fancy message here" -} -``` diff --git a/documents/tachyon/readme.md b/documents/tachyon/readme.md deleted file mode 100644 index ac40d27d1..000000000 --- a/documents/tachyon/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -## Tachyon protocol -Tachyon is a protocol specification as defined in [the Tachyon repo](https://github.com/beyond-all-reason/tachyon). If you want to see the specs for the protocol you will need to go there. This document is for documenting/describing the Teiserver implementation and internals of the protocol. - -## Request handlers -For handling protocol requests - -```elixir -defmodule Teiserver.Tachyon.Handlers.{Section}.{Action}Request do - @moduledoc false - - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.{Section}.{Action}Response - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "{section}/{action}/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, _object, _meta) do - # Do stuff here - - # Create the response - response = {Action}Response.generate(:ok) - - # Send the response and updated conn object - {response, %{conn | lobby_host: false, lobby_id: nil}} - end -end -``` - -If you implement the correct module naming convention and `dispatch_handlers` function it will be automatically loaded by `Teiserver.Tachyon.CommandDispatch` on startup. If you need to reload the dispatches you can use `Teiserver.Tachyon.CommandDispatch.build_dispatch_cache()`. - -## Response generators -For creating protocol responses - -## Message handlers -These are for handling internal PubSub messages - - diff --git a/documents/tachyon/server_comms.md b/documents/tachyon/server_comms.md deleted file mode 100644 index f1abc3650..000000000 --- a/documents/tachyon/server_comms.md +++ /dev/null @@ -1,3 +0,0 @@ -## -A set of commands allowing the client and server to communicate with each other for things other than chat (e.g. voting, moderation, accolades and other such features). - diff --git a/documents/tachyon/system.md b/documents/tachyon/system.md deleted file mode 100644 index 03e858f42..000000000 --- a/documents/tachyon/system.md +++ /dev/null @@ -1,100 +0,0 @@ -## Client initiated -### c.system.ping -No arguments - -#### Success response -Responds with a pong and the system time. This time can be used to calculate offsets between the local time and server time. - -#### Example input/output -```json -{ - "cmd": "c.system.ping" -} - -{ - "cmd": "s.system.pong", - "time": 123456789 -} -``` - -### c.system.watch -Subscribes you to updates updates for a given pubsub channel. - -```json -{ - "cmd": "c.system.watch", - "channel": "lobby:123" -} - -{ - "cmd": "s.system.watch", - "result": "success", - "channel": "lobby:123" -} - -{ - "cmd": "s.system.watch", - "result": "failure", - "reason": "No lobby", - "channel": "lobby:123" -} -``` - -#### Possible channel names: -**`server_stats`** -Every 9-10 seconds you will be sent a list of some server stats showing the current state of the server. -```json -{ - "cmd": "s.server.server_stats", - "data": { - "user_count": 10, - "player_count": 6, - "lobby_count": 4, - "in_progress_lobby_count": 2 - } -} -``` - -##### `all_lobbies` -Subscribes you to global lobby updates such as lobbies opening, closing and updating. - -##### `lobby:` -Subscribes you to lobby updates for a given lobby without joining it. Does not subscribe you to the lobby chat and if you join then leave a lobby you will need to resubscribe to it. - -##### `friends` -Subscribes you to information about each of your friends at the time of calling. If you add/remove a friend this will not updated an you will need to watch/unwatch using `friend:`. If you attempt to watch someone who is not a friend you will get a failure response. - -All friends-watch related messages are listed in [client.md](client.md). - -### c.system.unwatch -Unsubscribes you to the lobby updates for that particular lobby. Note if you are a member of a lobby it is inadvisable to call this for that lobby. -```json -{ - "cmd": "c.lobby.unwatch", - "lobby_id": 123 -} - -{ - "cmd": "s.lobby.unwatch", - "result": "success", - "lobby_id": 123 -} -``` - -## Server initiated -#### s.system.server_event -Instructs the application of an event taking place on the server. - -#### Arguments -event :: "server_restart" - -#### Event types -**server_restart** - Indicates the server is in the process of or about to restart. This means it will not respond to commands or send updated data until the restart has taken place. - -#### Examples -```json -{ - "cmd": "c.system.server_event", - "event": "server_restart" -} -``` diff --git a/documents/tachyon/telemetry.md b/documents/tachyon/telemetry.md deleted file mode 100644 index 2db19a3a1..000000000 --- a/documents/tachyon/telemetry.md +++ /dev/null @@ -1,40 +0,0 @@ -## Auth vs Unauth -The telemetry system is designed to work both with and without being authenticated. If you send commands, send them via the same connection as your normal commands and the server will automatically assign them to a user if it can. If there is no user to attach the information to it will be saved against the hash. The hash can be any printable string value (we advise base64 of a randomly written hash). - -## Properties and Events -Properties are values that are stored against the user/hash, when a new value is added it will replace the old value. This is intended for things such as tracking computer specs. Events are tracked against both the user/hash and a timestamp meaning you can log an event multiple times. - -Both events and properties are fire and forget in nature, you will not get a server response when sending them. - -### `c.telemetry.update_property` -hash: String -property: String -value: String - -#### Example input/output -```json -{ - "cmd": "c.telemetry.update_property", - "hash": "abcdefg", - "property": "my_property", - "value": "value" -} -``` - -### `c.telemetry.log_event` -hash: String -event: String -value: JSON Map - -#### Example input/output -```json -{ - "cmd": "c.telemetry.log_event", - "hash": "abcdefg", - "event": "my_property", - "value": { - "key1": "value", - "key2": [1,2,3] - } -} -``` diff --git a/documents/tachyon/types.md b/documents/tachyon/types.md deleted file mode 100644 index db14eb514..000000000 --- a/documents/tachyon/types.md +++ /dev/null @@ -1,297 +0,0 @@ -## Types -Tachyon defines types for all objects wherever possible. Users of the spec are expected to adhere to these types when using it. - - -## User -* id :: integer -* name :: string -* bot :: boolean, default: false -* clan_id :: Clan.id, default: nil -* icons :: map (string -> string) -- Badge type as the key, badge icon as the value (e.g. rank => level5) - -### Private properties, only sent to the account in question or to special privileged commands -* permissions :: list (string) -* friends :: list (User.id) -* friend_requests :: list (User.id) -- Users requesting this user to be their friend -* ignores :: list (User.id) - -#### Examples -```json -{ - "id": 1967, - "name": "Gerald Feinberg", - "skill": { - "1v1": 500, - "2v2": 634, - }, - "icons": { - "time_played": "400", - "current_season": "bertha", - "last_season": "korgoth", - } -} - -{ - "id": 1967, - "name": "Gerald Feinberg", - "skill": { - "1v1": 500, - "2v2": 634, - }, - "icons": { - "time_played": "400", - "current_season": "bertha", - "last_season": "korgoth", - }, - "permissions": ["moderator", "beta-tester"], - "friends": [1,2,3], - "friend_requests": [4,5,6], - "ignores": [7,8,9] -} -``` - -## Client -This represents a user who is logged in. A user who is logged out will not have a client object. -* id :: User.id -* in_game: boolean -* away: boolean - --- Game/Lobby attributes -* ready: boolean -* player_number: integer -* team_number: integer -- I want to rename this and the previous one to make it less confusing -* team_colour: colour -* player: boolean -* bonus: integer, default: 0 -- In spring this is 0-127, here it's an unsigned integer -* sync: map -- key represents the item with a value between 0-1 showing the percentage downloaded -* faction: string -* lobby_id: Lobby.id - --- Other -- -* party_id: string -* clan_tag: string -* muted: boolean - -#### Examples -```json -{ - "id": 1967, - "in_game": true, - "away": false, - "ready": true, - "player": true, - "team_number": 1, - "team_colour": "#AA9900", - "sync": { - "map": 1, - "engine": 0, - "game": 1 - }, - "faction": "random", - "lobby_id": 5, - "party_id": "abc-def", - "clan_tag": "TEH", - "muted": false -} -``` - -## Lobby -* id :: integer -* name :: string -* founder_id :: User.id -* passworded :: boolean -* locked :: string -- unlocked, friends, whitelist, locked -* engine_name :: string -* engine_version :: string -* players :: list (User.id) -* spectators :: list (User.id) -* bots :: list (User.id) -* ip :: string -* settings :: map :: (string -> any) -- Replaces spring's scripttags, disabled units and should go here I think -* start_areas :: map :: (id -> [type, x1, y1, x2, y2]) -* map_name :: string -* map_hash :: string -* public :: boolean - -#### Examples -```json -{ - "id": 9556, - "name": "EU 07 - 670", - "founder_id": 1967, - "passworded": false, - "locked": "unlocked", - "engine_name": "BAR", - "engine_version": "145.789-rc3", - "players": [1,2,3,4], - "spectators": [5,6,7], - "bots": [900], - "ip": "127.0.0.1", - "settings": { - "max_players": 16, - "type": "team", - "disabled_units": ["unit1", "unit2", "unit3"], - "start_areas": { - "1": ["rect", 0, 0, 100, 100], - "2": ["rect", 300, 300, 400, 400] - } - }, - "map_name": "koom valley", - "map_hash": "hash_string_here", - "public": true -} -``` - -## Queue -A queue used in matchmaking - -* id :: integer -* name :: string -* team_size :: integer -* conditions :: map (string -> string???) -* settings :: map (string -> any) -- Might not be needed, might be server side only -* map_list :: list (string) - -#### Examples -```json -{ - "id": 1967, - "name": "Competitive 1v1", - "team_size": 1, - "conditions": { - - }, - "settings": { - "allow_spectators": false, - "allow_pauses": false - }, - "map_list": ["avalanche", "quicksilver"] -} -``` - -## Party -1 or more players grouped together for the purpose of play and communication. -* id :: String/UUID -* leader :: User.id -* members :: list(User.id) -* invites :: list(User.id) -- A list of users currently being invited to the party - -#### Examples -```json -{ - "id": "3cd51300-c8ce-11ec-9db7-f02f74dbae33", - "leader": 123, - "members": [123, 456, 789], - "invites": [222, 444] -} -``` - -## BlogPost -An item posted to the site blog - -* id :: integer -* short_content :: string -* content :: string *The full content of the post* -* url :: string -* tags :: list (string) -* live_from :: timestamp - -Still thinking about how to best represent these: -* poster -* category -* comment_count - -## BlogComment -A comment attached to a blog post - -* content :: string -* commenter :: user -* timestamp :: timestamp - -## UserConfigType -Built on top of the Teiserver.Config data structures and used in `c.config._user*` - -* default :: string -* description :: string -* key :: string -* opts :: map -* section :: string -* type :: boolean -* value_label :: string - -#### Examples -```json - %{ - "default": true, - "description": "When checked the flag associated with your IP will be displayed. If unchecked your flag will be blank. This will take effect next time you login with your client.", - "key": "teiserver.Show flag", - "opts": {}, - "section": "Teiserver account", - "type": "boolean", - "value_label": "Value" - } -``` - -## Error -Returned when an unexpected error is generated. The difference between an error and a failure is the failure is an expected possible outcome (e.g. login failing) while an error is unexpected (e.g. message cannot be decoded). As such the error field will not always have the command being executed (though may sometimes). - -#### Examples -```json -{ - "result": "error", - "error": "base64_decode", - "location": "decode" -} -``` - - diff --git a/documents/tachyon/user.md b/documents/tachyon/user.md deleted file mode 100644 index 131895bd6..000000000 --- a/documents/tachyon/user.md +++ /dev/null @@ -1,162 +0,0 @@ -### c.user.list_users_from_ids -Returns a list of users as listed by the ids. - -#### Arguments -`id_list` - list (User.id) - -##### Optional -`include_clients` - Boolean - default false - -#### Response -* users :: List (User) - -#### Example input/output -```json -{ - "cmd": "c.user.list_users_from_ids", - "id_list": [1, 2, 3], - "include_clients": true -} - -// Without clients -{ - "cmd": "s.user.user_list", - "users": [ - User, - User, - User - ] -} - -// With clients -{ - "cmd": "s.user.user_list", - "users": [ - User, - User, - User - ], - "clients": [ - Client, - Client, - Client - ] -} -``` - -### c.user.list_friend_ids -Returns a list of user ids of those on your friend list and any requests you have awaiting your approval. - -#### Example input/output -```json -{ - "cmd": "c.user.list_friend_ids" -} - -{ - "cmd": "s.user.list_friend_ids", - "friend_id_list": [1, 2, 3], - "request_id_list": [4, 5, 6] -} -``` - -### c.user.list_friend_users_and_clients -Returns a all users of your friends and clients of those that are logged in. Will specifically return information about the party of the clients as they are your friends. - -#### Example input/output -```json -{ - "cmd": "c.user.list_friend_users_and_clients" -} - -{ - "cmd": "s.user.list_friend_users_and_clients", - "user_list": [ - User, - User, - User - ], - "client_list": [ - Client, - Client, - Client - ] -} -``` - -#### Other user stuff -- Mute/unmute -- Add note - -## Friends -### c.user.add_friend -Sends a friend request to a user. -```json -{ - "cmd": "c.user.add_friend", - "user_id": userid -} -``` - -### s.user.friend_request -The server informing you of a new friend request. -```json -{ - "cmd": "s.user.friend_request", - "user_id": userid -} -``` - -### c.user.rescind_friend_request -Rescinds your previously sent friend request. -```json -{ - "cmd": "c.user.rescind_friend_request", - "user_id": userid -} -``` - -### c.user.accept_friend_request -Accepting a request to be friends. If it succeeds you should get a `s.user.new_friend` message. -```json -{ - "cmd": "c.user.accept_friend_request", - "user_id": userid -} -``` - -### s.user.friend_added -The server informing you of a new friend. -```json -{ - "cmd": "s.user.friend_added", - "user_id": userid -} -``` - -### c.user.reject_friend_request -Rejects the friend request, the other user is not notified of this. -```json -{ - "cmd": "s.user.reject_friend_request", - "user_id": userid -} -``` - -### c.user.remove_friend -Removes someone as a friend, the other user is notified of this. You should receive a `s.user.friend_removed` response. -```json -{ - "cmd": "c.user.remove_friend", - "user_id": userid -} -``` - -### s.user.friend_removed -Informing you a friend has been removed. -```json -{ - "cmd": "s.user.friend_removed", - "user_id": userid -} -``` diff --git a/lib/teiserver.ex b/lib/teiserver.ex index 19ba73707..3e0c86534 100644 --- a/lib/teiserver.ex +++ b/lib/teiserver.ex @@ -26,12 +26,6 @@ defmodule Teiserver do :code.load_file(module) end - # Designed for debugging help - @spec tachyon(String.t() | :timeout) :: {:ok, List.t() | Map.t()} | {:error, :bad_json} - def tachyon(v) do - Teiserver.Protocols.TachyonLib.decode(v) - end - @spec accolade_status :: nil | :ok def accolade_status() do Application.put_env(:elixir, :ansi_enabled, true) diff --git a/lib/teiserver/application.ex b/lib/teiserver/application.ex index 0e14f2fe4..e10d99959 100644 --- a/lib/teiserver/application.ex +++ b/lib/teiserver/application.ex @@ -56,7 +56,6 @@ defmodule Teiserver.Application do Teiserver.MetadataCache, concache_sup(:application_temp_cache), concache_sup(:config_user_cache), - Teiserver.Tachyon.Cache, # Teiserver stuff # Global/singleton registries @@ -168,10 +167,6 @@ defmodule Teiserver.Application do %{ id: Teiserver.RawSpringTcpServer, start: {Teiserver.SpringTcpServer, :start_link, [[]]} - }, - %{ - id: Teiserver.TachyonTcpServer, - start: {Teiserver.TachyonTcpServer, :start_link, [[]]} } ] ++ discord_start() diff --git a/lib/teiserver/data/cache_user.ex b/lib/teiserver/data/cache_user.ex index 0618fc01a..cca8ccea4 100644 --- a/lib/teiserver/data/cache_user.ex +++ b/lib/teiserver/data/cache_user.ex @@ -302,9 +302,6 @@ defmodule Teiserver.CacheUser do String.ends_with?(user.email, "@hailstorm_spring") -> :ok - String.ends_with?(user.email, "@hailstorm_tachyon") -> - :ok - true -> case EmailHelper.new_user(user) do {:error, error} -> @@ -811,97 +808,6 @@ defmodule Teiserver.CacheUser do Config.get_site_config_cache("system.User limit") - client_count end - @spec ip_to_string(String.t() | tuple()) :: Tuple.t() - defp ip_to_string({a, b, c, d}) do - "#{a}.#{b}.#{c}.#{d}" - end - - defp ip_to_string(ip) do - to_string(ip) - end - - @spec login_from_token(String.t(), map()) :: - {:ok, T.user()} | {:error, String.t()} | {:error, String.t(), T.userid()} - def login_from_token(token, ws_state) do - ip = get_in(ws_state, [:connect_info, :peer_data, :address]) |> ip_to_string - _user_agent = get_in(ws_state, [:connect_info, :user_agent]) - application_hash = ws_state.params["application_hash"] - application_name = ws_state.params["application_name"] - application_version = ws_state.params["application_version"] - - wait_for_startup() - - user = get_user_by_id(token.user.id) - - # # If they're a smurf, log them in as the smurf! - # user = - # if user.smurf_of_id != nil do - # get_user_by_id(user.smurf_of_id) - # else - # user - # end - - cond do - user.smurf_of_id != nil -> - Telemetry.log_complex_server_event(user.id, "Banned login", %{ - error: "Smurf" - }) - - {:error, @smurf_string} - - token.expires != nil and Timex.compare(token.expires, Timex.now()) == -1 -> - {:error, "Token expired"} - - not is_bot?(user) and login_flood_check(user.id) == :block -> - {:error, "Flood protection - Please wait 20 seconds and try again"} - - Enum.member?(["", "0", nil], application_hash) == true -> - {:error, "Application hash missing in login"} - - is_restricted?(user, ["Permanently banned"]) -> - Telemetry.log_complex_server_event(user.id, "Banned login", %{ - error: "Permanently banned" - }) - - {:error, "Banned account"} - - is_restricted?(user, ["Login"]) -> - Telemetry.log_complex_server_event(user.id, "Banned login", %{ - error: "Suspended" - }) - - {:error, @suspended_string} - - not is_verified?(user) -> - Account.update_user_stat(user.id, %{ - application_name: application_name, - application_version: application_version, - application_hash: application_hash, - last_ip: ip - }) - - {:error, "Unverified", user.id} - - Client.get_client_by_id(user.id) != nil -> - Client.disconnect(user.id, "Already logged in") - - if is_bot?(user) do - :timer.sleep(1000) - do_login(user, ip, application_name, application_hash) - else - Teiserver.cache_put(:teiserver_login_count, user.id, 10) - {:error, "Existing session, please retry in 20 seconds to clear the cache"} - end - - true -> - {:ok, user} = do_login(user, ip, application_name, application_hash) - - _client = Client.login(user, :tachyon, ip) - - {:ok, user} - end - end - @spec try_login(String.t(), String.t(), String.t(), String.t()) :: {:ok, T.user()} | {:error, String.t()} | {:error, String.t(), T.userid()} def try_login(token, ip, lobby, lobby_hash) do diff --git a/lib/teiserver/data/types.ex b/lib/teiserver/data/types.ex index 0b464afde..9b2d85a3a 100644 --- a/lib/teiserver/data/types.ex +++ b/lib/teiserver/data/types.ex @@ -21,14 +21,6 @@ defmodule Teiserver.Data.Types do @type user() :: map() @type spring_tcp_state() :: map() - @type tachyon_tcp_state() :: map() - @type tachyon_ws_state() :: map() - - @type tachyon_conn() :: map() - @type tachyon_command() :: String.t() - @type tachyon_object() :: map() - @type tachyon_response() :: - {tachyon_command(), :success, tachyon_object()} | {T.tachyon_command(), T.error_pair()} @type error_pair() :: {:error, String.t()} @type lobby_server_state() :: map() diff --git a/lib/teiserver/libs/teiserver_configs.ex b/lib/teiserver/libs/teiserver_configs.ex index 27024b286..d49f86f98 100644 --- a/lib/teiserver/libs/teiserver_configs.ex +++ b/lib/teiserver/libs/teiserver_configs.ex @@ -198,24 +198,6 @@ defmodule Teiserver.TeiserverConfigs do default: 6 }) - add_site_config_type(%{ - key: "teiserver.Tachyon flood rate limit count", - section: "Legacy protocol", - type: "integer", - permissions: ["Admin"], - description: "The number of commands required to trip flood protection for Tachyon", - default: 20 - }) - - add_site_config_type(%{ - key: "teiserver.Tachyon flood rate window size", - section: "Legacy protocol", - type: "integer", - permissions: ["Admin"], - description: "The size of the window in seconds for flood protection to trip for Tachyon", - default: 6 - }) - add_site_config_type(%{ key: "teiserver.Ring flood rate limit count", section: "Legacy protocol", diff --git a/lib/teiserver/protocols/spring/spring_in.ex b/lib/teiserver/protocols/spring/spring_in.ex index 8c6d42c18..216f07296 100644 --- a/lib/teiserver/protocols/spring/spring_in.ex +++ b/lib/teiserver/protocols/spring/spring_in.ex @@ -150,34 +150,6 @@ defmodule Teiserver.Protocols.SpringIn do reply(:welcome, nil, msg_id, new_state) end - # Swap to the Tachyon protocol - defp do_handle("TACHYON", "", msg_id, state) do - reply(:okay, "TACHYON", msg_id, state) - {m_in, m_out} = Teiserver.Protocols.TachyonLib.get_modules() - - %{state | protocol_in: m_in, protocol_out: m_out} - end - - defp do_handle("TACHYON", "dev", msg_id, state) do - reply(:okay, "TACHYON", msg_id, state) - {m_in, m_out} = Teiserver.Protocols.TachyonLib.get_modules("dev") - - %{state | protocol_in: m_in, protocol_out: m_out} - end - - defp do_handle("TACHYON", "v" <> _ = version, msg_id, state) do - reply(:okay, "TACHYON", msg_id, state) - {m_in, m_out} = Teiserver.Protocols.TachyonLib.get_modules(version) - - %{state | protocol_in: m_in, protocol_out: m_out} - end - - # Use the Tachyon protocol for a single command - defp do_handle("TACHYON", data, _msg_id, state) do - {m_in, _m_out} = Teiserver.Protocols.TachyonLib.get_modules() - m_in.data_in("#{data}\n", state) - end - defp do_handle("c.battles.list_ids", _, msg_id, state) do reply(:list_battles, Lobby.list_lobby_ids(), msg_id, state) state diff --git a/lib/teiserver/protocols/spring/spring_out.ex b/lib/teiserver/protocols/spring/spring_out.ex index ec08fe695..e8c53e3ce 100644 --- a/lib/teiserver/protocols/spring/spring_out.ex +++ b/lib/teiserver/protocols/spring/spring_out.ex @@ -20,7 +20,7 @@ defmodule Teiserver.Protocols.SpringOut do --------- """ - @compflags "sp teiserver matchmaking token-auth tachyon" + @compflags "sp teiserver matchmaking token-auth" @spec reply(atom(), nil | String.t() | tuple() | list(), String.t(), map) :: map def reply(reply_cmd, data, msg_id, state) do @@ -602,10 +602,6 @@ defmodule Teiserver.Protocols.SpringOut do "s.client.errorlog\n" end - # defp do_reply(:tachyon, {namespace, function, data, state}) do - # Teiserver.Protocols.Tachyon.V1.TachyonOut.reply(namespace, function, data, state) - # end - defp do_reply(atom, data) do Logger.error( "No reply match in spring_out.ex for atom: #{atom} and data: #{Kernel.inspect(data)}" diff --git a/lib/teiserver/protocols/tachyon_json_ws/cache.ex b/lib/teiserver/protocols/tachyon_json_ws/cache.ex deleted file mode 100644 index d4b31586d..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/cache.ex +++ /dev/null @@ -1,28 +0,0 @@ -defmodule Teiserver.Tachyon.Cache do - @moduledoc """ - Cache for tachyon schemas and dispatchers - """ - - use Supervisor - alias Teiserver.Helpers.CacheHelper - - def start_link(opts) do - with {:ok, sup} <- Supervisor.start_link(__MODULE__, :ok, opts), - {:ok, _schemas} <- Teiserver.Tachyon.Schema.load_schemas(), - :ok <- Teiserver.Tachyon.CommandDispatch.build_dispatch_cache() do - {:ok, sup} - end - end - - @impl true - def init(:ok) do - children = [ - CacheHelper.concache_perm_sup(:tachyon_schemas), - CacheHelper.concache_perm_sup(:tachyon_dispatches) - ] - - # we could have schema and dispatches under their own supervision tree each - # and their own init, but this is simpler - Supervisor.init(children, strategy: :one_for_all) - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/command_dispatch.ex b/lib/teiserver/protocols/tachyon_json_ws/command_dispatch.ex deleted file mode 100644 index 411304652..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/command_dispatch.ex +++ /dev/null @@ -1,63 +0,0 @@ -defmodule Teiserver.Tachyon.CommandDispatch do - @moduledoc """ - - """ - - def dispatch(conn, object, meta) do - handler = get_dispatch_handler(meta["command"]) - - handler.(conn, object, meta) - end - - defp get_dispatch_handler(command) do - # Get the relevant handler, if none found the no_command fallback will handle it - Teiserver.store_get(:tachyon_dispatches, command) || - Teiserver.store_get(:tachyon_dispatches, "no_command") - end - - @spec build_dispatch_cache :: :ok - def build_dispatch_cache do - # Get every single module in that namespace - # if it has a dispatch_handlers function we make use of it - {:ok, module_list} = :application.get_key(:teiserver, :modules) - - lookup = - module_list - |> Enum.filter(fn m -> - m |> Module.split() |> Enum.take(3) == ["Teiserver", "Tachyon", "Handlers"] - end) - |> Enum.filter(fn m -> - Code.ensure_loaded(m) - function_exported?(m, :dispatch_handlers, 0) - end) - |> Enum.reduce(%{}, fn module, acc -> - Map.merge(acc, module.dispatch_handlers()) - end) - - old = Teiserver.store_get(:tachyon_dispatches, "all") || [] - - # Store all keys, we'll use it later for removing old ones - Teiserver.store_put(:tachyon_dispatches, "all", Map.keys(lookup)) - - # Now store our lookups - lookup - |> Enum.each(fn {key, func} -> - Teiserver.store_put(:tachyon_dispatches, key, func) - end) - - # Special case - no_command_func = &Teiserver.Tachyon.Handlers.System.NoCommandErrorRequest.execute/3 - Teiserver.store_put(:tachyon_dispatches, "no_command", no_command_func) - - # Delete out-dated keys - old - |> Enum.reject(fn old_key -> - Map.has_key?(lookup, old_key) - end) - |> Enum.each(fn old_key -> - Teiserver.store_delete(:tachyon_dispatches, old_key) - end) - - :ok - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/converters.ex b/lib/teiserver/protocols/tachyon_json_ws/converters.ex deleted file mode 100644 index e5d5b6d7a..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/converters.ex +++ /dev/null @@ -1,92 +0,0 @@ -defmodule Teiserver.Tachyon.Converters do - @moduledoc """ - Used to convert objects from internal representations into json objects - for the protocol - """ - - require Logger - - @spec convert( - Map.t() | nil, - :user | :user_extended | :user_extended_icons | :client | :battle | :queue - ) :: Map.t() | nil - def convert(nil, _), do: nil - - def convert(objects, type) when is_list(objects) do - objects - |> Enum.map(fn object -> convert(object, type) end) - end - - def convert(user, :user) do - Map.merge( - Map.take(user, ~w(id name bot clan_id country)a), - %{"icons" => Teiserver.Account.UserLib.generate_user_icons(user)} - ) - end - - def convert(user, :user_extended), do: Map.take(user, ~w(id name bot clan_id permissions - friends friend_requests ignores country)a) - - def convert(user, :user_extended_icons) do - Map.merge( - convert(user, :user_extended), - %{"icons" => Teiserver.Account.UserLib.generate_user_icons(user)} - ) - end - - def convert(client, :client) do - sync_list = - case Map.get(client, :sync, nil) do - true -> ["game", "map"] - 1 -> ["game", "map"] - false -> [] - 0 -> [] - s -> s - end - - Map.take(client, ~w(userid in_game away ready player_number - team_number team_colour player bonus muted clan_tag - faction lobby_id)a) - |> Map.put(:sync, sync_list) - |> Map.put(:party_id, nil) - end - - def convert(client, :client_friend) do - sync_list = - case client.sync do - true -> ["game", "map"] - 1 -> ["game", "map"] - false -> [] - 0 -> [] - s -> s - end - - Map.take(client, ~w(userid in_game away ready player_number - team_number team_colour player bonus muted party_id clan_tag - faction lobby_id)a) - |> Map.put(:sync, sync_list) - end - - def convert(queue, :queue), - do: Map.take(queue, ~w(id name team_size conditions settings map_list)a) - - def convert(party, :party_full), - do: Map.take(party, ~w(id leader members pending_invites)a) - - def convert(party, :party_public), do: Map.take(party, ~w(id leader members)a) - - def convert(type, :user_config_type) do - opts = type[:opts] |> Map.new() - - Map.take(type, ~w(default description key section type value_label)a) - |> Map.put(:opts, opts) - end - - # Slightly more complex conversions - def convert(lobby, :lobby) do - Map.take(lobby, ~w(id name founder_id type max_players game_name - locked engine_name engine_version players spectators bots ip port - settings map_name passworded public - map_hash tags disabled_units in_progress started_at start_areas)a) - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/account/whoami_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/account/whoami_request.ex deleted file mode 100644 index c99d96cb6..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/account/whoami_request.ex +++ /dev/null @@ -1,26 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Account.WhoamiRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.Account.WhoamiResponse - alias Teiserver.Account - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "account/whoAmI/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, _object, _meta) do - user = Account.get_user_by_id(conn.userid) - client = Account.get_client_by_id(conn.userid) - - response = WhoamiResponse.generate(user, client) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/communication/send_direct_message_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/communication/send_direct_message_request.ex deleted file mode 100644 index fa7a42e08..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/communication/send_direct_message_request.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Communication.SendDirectMessageRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.Communication.SendDirectMessageResponse - alias Teiserver.CacheUser - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "communication/sendDirectMessage/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, object, _meta) do - result = CacheUser.send_direct_message(conn.userid, object["to"], object["message"]) - - response = SendDirectMessageResponse.generate(result) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/join_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/join_request.ex deleted file mode 100644 index 26c4fad34..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/join_request.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Lobby.JoinRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Battle - alias Teiserver.Tachyon.Responses.Lobby.JoinResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobby/join/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, %{"lobby_id" => lobby_id} = object, _meta) do - result = Battle.can_join?(conn.userid, lobby_id, object["password"]) - - response = JoinResponse.generate(result) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/leave_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/leave_request.ex deleted file mode 100644 index bedd72b1e..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/leave_request.ex +++ /dev/null @@ -1,31 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Lobby.LeaveRequest do - @moduledoc """ - - """ - alias Phoenix.PubSub - alias Teiserver.Lobby - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.Lobby.LeaveResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobby/leave/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, _object, _meta) do - # Remove them from all the battles anyways, just in case - Lobby.remove_user_from_any_lobby(conn.userid) - |> Enum.each(fn lobby_id -> - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - end) - - response = LeaveResponse.generate(:ok) - - {response, %{conn | lobby_host: false, lobby_id: nil}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/list_lobbies_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/list_lobbies_request.ex deleted file mode 100644 index 987cdfbf1..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/list_lobbies_request.ex +++ /dev/null @@ -1,28 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Lobby.ListLobbiesRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Converters - alias Teiserver.Battle - alias Teiserver.Tachyon.Responses.Lobby.ListLobbiesResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobby/list_lobbies/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, _object, _meta) do - lobbies = - Battle.list_lobbies() - |> Converters.convert(:lobby) - - response = ListLobbiesResponse.generate(lobbies) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/update_status_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/update_status_request.ex deleted file mode 100644 index f124ec062..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby/update_status_request.ex +++ /dev/null @@ -1,58 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Lobby.UpdateStatusRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.Lobby.UpdateStatusResponse - alias Teiserver.{Lobby, Coordinator, Client, Account} - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobby/updateStatus/request" => &execute/3 - } - end - - @keys %{ - "is_player" => :player - } - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, status, _meta) do - existing = Client.get_client_by_id(conn.userid) - - updates = - @keys - |> Enum.filter(fn {string_key, _atom_key} -> - Map.has_key?(status, string_key) - end) - |> Map.new(fn {string_key, atom_key} -> - {atom_key, status[string_key]} - end) - - potential_new = Map.merge(existing, updates) - - _result = - if Lobby.allow?(conn.userid, :mybattlestatus, conn.lobby_id) do - case Coordinator.attempt_battlestatus_update(potential_new, conn.lobby_id) do - {true, allowed_client} -> - updated_values = - updates - |> Map.keys() - |> Map.new(fn key -> - {key, Map.get(allowed_client, key)} - end) - - Account.merge_update_client(conn.userid, updated_values) - - nil -> - :ok - end - end - - response = UpdateStatusResponse.generate() - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_chat/say_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_chat/say_request.ex deleted file mode 100644 index 4bc21e69d..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_chat/say_request.ex +++ /dev/null @@ -1,36 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.LobbyChat.SayRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Lobby - alias Teiserver.Tachyon.Responses.LobbyChat.SayResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobbyChat/say/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(%{lobby_id: nil} = conn, _, _meta) do - response = SayResponse.generate(:no_lobby) - {response, conn} - end - - def execute(conn, %{"message" => message}, _meta) do - result = - if Lobby.allow?(conn.userid, :saybattle, conn.lobby_id) do - Lobby.say(conn.userid, message, conn.lobby_id) - true - else - false - end - - response = SayResponse.generate(result) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/create_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/create_request.ex deleted file mode 100644 index 3ce841f90..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/create_request.ex +++ /dev/null @@ -1,42 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.LobbyHost.CreateRequest do - @moduledoc false - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.LobbyHost.CreateResponse - alias Teiserver.{Lobby, Account} - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobbyHost/create/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, object, _meta) do - user = Account.get_user_by_id(conn.userid) - client = Account.get_client_by_id(conn.userid) - - object = - Map.merge(object, %{ - "founder_id" => conn.userid, - "founder_name" => user.name, - "ip" => client.ip - }) - - lobby = Lobby.create_new_lobby(object) - - response = CreateResponse.generate(lobby) - - new_conn = - case lobby do - {:ok, %{id: lobby_id}} -> - %{conn | lobby_id: lobby_id} - - _ -> - conn - end - - {response, new_conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/respond_to_join_request_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/respond_to_join_request_request.ex deleted file mode 100644 index 13997fc49..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/lobby_host/respond_to_join_request_request.ex +++ /dev/null @@ -1,29 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.LobbyHost.RespondToJoinRequestRequest do - @moduledoc false - alias Teiserver.Data.Types, as: T - alias Teiserver.Lobby - alias Teiserver.Tachyon.Responses.LobbyHost.RespondToJoinRequestResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "lobbyHost/respondToJoinRequest/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, %{"response" => "accept"} = object, _meta) do - Lobby.accept_join_request(object["userid"], conn.lobby_id) - - response = RespondToJoinRequestResponse.generate(:ok) - {response, conn} - end - - def execute(conn, %{"response" => "deny", "reason" => reason} = object, _meta) do - Lobby.deny_join_request(object["userid"], conn.lobby_id, reason) - - response = RespondToJoinRequestResponse.generate(:ok) - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/disconnect_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/system/disconnect_request.ex deleted file mode 100644 index 3a7172391..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/disconnect_request.ex +++ /dev/null @@ -1,27 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.System.DisconnectRequest do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.System.DisconnectResponse - - # @command_id "system/error" - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "disconnect" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(%{userid: userid} = conn, _object, _meta) do - send(self(), :disconnect) - Teiserver.Client.disconnect(userid, "WS disconnect request") - - response = DisconnectResponse.generate("disconnected") - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/force_error_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/system/force_error_request.ex deleted file mode 100644 index b09b80f48..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/force_error_request.ex +++ /dev/null @@ -1,26 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.System.ForceErrorRequest do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "force_error" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, %{"command" => command}, _meta) do - {{command, %{}}, conn} - end - - def execute(_conn, _object, _meta) do - raise "Forced error" - - {{"force_error", %{}}, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/no_command_error_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/system/no_command_error_request.ex deleted file mode 100644 index 1e67221a1..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/no_command_error_request.ex +++ /dev/null @@ -1,29 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.System.NoCommandErrorRequest do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.System.ErrorResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "no_command" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, _object, %{"command" => command} = _meta) do - response = ErrorResponse.generate("No command of '#{command}'") - - {response, conn} - end - - def execute(conn, _object, _meta) do - response = ErrorResponse.generate("No command supplied") - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/ping_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/system/ping_request.ex deleted file mode 100644 index d07ffd045..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/system/ping_request.ex +++ /dev/null @@ -1,22 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.System.PingRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.System.PingResponse - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "system/ping/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, _object, _meta) do - response = PingResponse.generate(conn) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/event_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/event_request.ex deleted file mode 100644 index 19e383feb..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/event_request.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Telemetry.EventRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.Telemetry.EventResponse - alias Teiserver.{Telemetry} - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "telemetry/event/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, %{"type" => event_type, "value" => value}, _meta) do - Telemetry.log_complex_client_event(conn.userid, event_type, value) - - response = EventResponse.generate(:ok) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/property_request.ex b/lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/property_request.ex deleted file mode 100644 index a81f0ef0f..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/handlers/telemetry/property_request.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Teiserver.Tachyon.Handlers.Telemetry.PropertyRequest do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.Telemetry.PropertyResponse - alias Teiserver.{Telemetry} - - @spec dispatch_handlers :: map() - def dispatch_handlers() do - %{ - "telemetry/property/request" => &execute/3 - } - end - - @spec execute(T.tachyon_conn(), T.tachyon_object(), map) :: - {T.tachyon_response(), T.tachyon_conn()} - def execute(conn, %{"type" => property_type, "value" => value}, _meta) do - Telemetry.log_user_property(conn.userid, property_type, value) - - response = PropertyResponse.generate(:ok) - - {response, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/client_message_handlers.ex b/lib/teiserver/protocols/tachyon_json_ws/message_handlers/client_message_handlers.ex deleted file mode 100644 index 4c6b4f45d..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/client_message_handlers.ex +++ /dev/null @@ -1,84 +0,0 @@ -defmodule Teiserver.Tachyon.MessageHandlers.ClientMessageHandlers do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Phoenix.PubSub - alias Teiserver.Tachyon.Responses.Communication.ReceivedDirectMessageResponse - alias Teiserver.Tachyon.Responses.Lobby.{ReceivedJoinRequestResponseResponse, JoinedResponse} - alias Teiserver.Tachyon.Responses.User.UpdatedUserClientResponse - - @spec handle(map(), T.tachyon_conn()) :: - {:ok, T.tachyon_conn()} | {:ok, map() | list(), T.tachyon_conn()} - def handle(%{event: :received_direct_message} = msg, conn) do - case ReceivedDirectMessageResponse.generate(msg) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :join_lobby_request_response} = msg, conn) do - case ReceivedJoinRequestResponseResponse.generate(msg) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :client_updated} = msg, conn) do - case UpdatedUserClientResponse.generate(msg.client) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :added_to_lobby, lobby_id: lobby_id} = msg, conn) - when is_integer(lobby_id) do - case JoinedResponse.generate(lobby_id, msg.script_password) do - {command, :success, data} -> - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, %{conn | lobby_id: lobby_id}} - end - end - - def handle(%{event: :connected} = _msg, conn) do - {:ok, [], conn} - end - - def handle(%{event: :disconnected} = _msg, conn) do - {:ok, [], conn} - end - - def handle(msg, conn) do - raise "No handler for msg of '#{inspect(msg.event)}' in ClientMessageHandlers" - {:ok, [], conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_chat_message_handlers.ex b/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_chat_message_handlers.ex deleted file mode 100644 index 79c77c5b5..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_chat_message_handlers.ex +++ /dev/null @@ -1,40 +0,0 @@ -defmodule Teiserver.Tachyon.MessageHandlers.LobbyChatMessageHandlers do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.LobbyChat.SaidResponse - - @spec handle(map(), T.tachyon_conn()) :: - {:ok, T.tachyon_conn()} | {:ok, map() | list(), T.tachyon_conn()} - def handle(%{event: :say} = msg, conn) do - case SaidResponse.generate(msg.userid, msg.lobby_id, msg.message) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - # def handle(%{event: :remove_user} = msg, conn) do - # case RemoveUserClientResponse.generate(msg.client.userid, msg.lobby_id) do - # {command, :success, data} -> - # resp = %{ - # "command" => command, - # "status" => "success", - # "data" => data - # } - - # {:ok, resp, conn} - # end - # end - - def handle(msg, conn) do - raise "No handler for msg of #{msg.event} in LobbyChatMessageHandlers" - {:ok, [], conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_host_message_handlers.ex b/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_host_message_handlers.ex deleted file mode 100644 index 3033740f5..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_host_message_handlers.ex +++ /dev/null @@ -1,31 +0,0 @@ -defmodule Teiserver.Tachyon.MessageHandlers.LobbyHostMessageHandlers do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Responses.LobbyHost.JoinRequestReponse - - @spec handle(map(), T.tachyon_conn()) :: - {:ok, T.tachyon_conn()} | {:ok, map() | list(), T.tachyon_conn()} - def handle(%{event: :user_requests_to_join} = msg, conn) do - case JoinRequestReponse.generate(msg.userid, msg.lobby_id) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :add_user} = msg, _conn) do - raise inspect(msg) - end - - def handle(msg, conn) do - raise "No handler for msg of #{msg.event} in LobbyHostMessageHandlers" - {:ok, [], conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_update_message_handlers.ex b/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_update_message_handlers.ex deleted file mode 100644 index 378f0ac05..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/message_handlers/lobby_update_message_handlers.ex +++ /dev/null @@ -1,79 +0,0 @@ -defmodule Teiserver.Tachyon.MessageHandlers.LobbyUpdateMessageHandlers do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - - alias Teiserver.Tachyon.Responses.Lobby.{ - AddUserClientResponse, - RemoveUserClientResponse, - ClosedResponse - } - - alias Teiserver.Tachyon.Responses.User.UpdatedUserClientResponse - require Logger - - @spec handle(map(), T.tachyon_conn()) :: - {:ok, T.tachyon_conn()} | {:ok, map() | list(), T.tachyon_conn()} - def handle(%{event: :add_user} = msg, conn) do - case AddUserClientResponse.generate(msg.client, msg.lobby_id) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :remove_user} = msg, conn) do - case RemoveUserClientResponse.generate(msg.client.userid, msg.lobby_id) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :updated_client_battlestatus} = msg, conn) do - case UpdatedUserClientResponse.generate(msg.userid, msg.client) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :closed} = msg, conn) do - case ClosedResponse.generate(msg.lobby_id) do - {command, :success, data} -> - resp = %{ - "command" => command, - "status" => "success", - "data" => data - } - - {:ok, resp, conn} - end - end - - def handle(%{event: :update_values}, conn) do - Logger.error("No handler for msg of :update_values in LobbyUpdateMessageHandlers") - {:ok, conn} - end - - def handle(msg, conn) do - raise "No handler for msg of #{msg.event} in LobbyUpdateMessageHandlers" - {:ok, conn} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/account/whoami_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/account/whoami_response.ex deleted file mode 100644 index d4cc1b3f5..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/account/whoami_response.ex +++ /dev/null @@ -1,42 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Account.WhoamiResponse do - @moduledoc """ - Whoami response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/account.ts - """ - - alias Teiserver.Data.Types, as: T - alias Teiserver.{Account, CacheUser} - - @spec generate(T.user(), T.client()) :: - {T.tachyon_command(), T.tachyon_status(), T.tachyon_object()} - def generate(user, client) do - object = %{ - "id" => user.id, - "name" => user.name, - "is_bot" => CacheUser.is_bot?(user), - "clan_id" => user.clan_id, - "icons" => %{}, - "roles" => [], - "permissions" => user.permissions, - "friends" => Account.list_friend_ids_of_user(user.id), - "friend_requests" => Account.list_incoming_friend_requests_of_userid(user.id), - "ignores" => Account.list_userids_ignored_by_userid(user.id), - "status" => %{ - "in_game" => client.in_game, - "away" => client.away, - "ready" => client.ready, - "player_number" => client.player_number, - "team_colour" => client.team_colour, - "is_player" => client.player, - "bonus" => client.handicap, - "sync" => client.sync, - "faction" => "???", - "lobby_id" => client.lobby_id, - "party_id" => client.party_id, - "clan_tag" => client.clan_tag, - "muted" => client.muted - } - } - - {"account/whoAmI/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/communication/received_direct_message_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/communication/received_direct_message_response.ex deleted file mode 100644 index 6392b6e79..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/communication/received_direct_message_response.ex +++ /dev/null @@ -1,24 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Communication.ReceivedDirectMessageResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(atom) :: {T.tachyon_command(), T.tachyon_status(), T.tachyon_object()} - def generate(%{message_content: content, sender_id: sender_id}) do - content = - if is_list(content) do - Enum.join(content, "\n") - else - content - end - - resp = %{ - content: content, - sender_id: sender_id - } - - {"communication/receivedDirectMessage/response", :success, resp} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/communication/send_direct_message_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/communication/send_direct_message_response.ex deleted file mode 100644 index 7d0ec5d6b..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/communication/send_direct_message_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Communication.SendDirectMessageResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(atom) :: {T.tachyon_command(), T.tachyon_status(), T.tachyon_object()} - def generate(:ok) do - {"communication/sendDirectMessage/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/add_user_client_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/add_user_client_response.ex deleted file mode 100644 index 6e8fb9258..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/add_user_client_response.ex +++ /dev/null @@ -1,38 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.AddUserClientResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(T.client(), T.lobby_id()) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate(client, lobby_id) do - object = %{ - "id" => client.userid, - "name" => client.name, - "status" => %{ - "in_game" => client.in_game, - "away" => client.away, - "ready" => client.ready, - "player_number" => client.player_number, - "team_colour" => client.team_colour, - "is_player" => client.player, - "bonus" => client.handicap, - "sync" => client.sync, - "faction" => "???", - "lobby_id" => client.lobby_id, - "party_id" => client.party_id, - "clan_tag" => client.clan_tag, - "muted" => client.muted - } - } - - {"lobby/addUserClient/response", :success, - %{ - "lobby_id" => lobby_id, - "UserClient" => object - }} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/closed_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/closed_response.ex deleted file mode 100644 index 5cbd183c3..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/closed_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.ClosedResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(T.lobby_id()) :: T.tachyon_response() - def generate(lobby_id) do - {"lobby/closed/response", :success, %{"lobby_id" => lobby_id}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/join_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/join_response.ex deleted file mode 100644 index 9b23cd3b6..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/join_response.ex +++ /dev/null @@ -1,22 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.JoinResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate({:error, String.t()} | T.lobby()) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate({:error, reason}) do - {"system/error/response", {:error, reason}} - end - - def generate({:failure, reason}) do - {"lobby/join/response", :success, %{"result" => "failure", "reason" => reason}} - end - - def generate({:waiting_on_host, _script_password}) do - {"lobby/join/response", :success, %{"result" => "waiting_on_host"}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/joined_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/joined_response.ex deleted file mode 100644 index fa77b546b..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/joined_response.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.JoinedResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(T.lobby_id(), String.t()) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate(lobby_id, script_password) when is_integer(lobby_id) do - {"lobby/joined/response", :success, - %{ - "lobby_id" => lobby_id, - "script_password" => script_password - }} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/leave_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/leave_response.ex deleted file mode 100644 index 798a4a291..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/leave_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.LeaveResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(:ok) :: T.tachyon_response() - def generate(:ok) do - {"lobby/leave/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/list_lobbies_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/list_lobbies_response.ex deleted file mode 100644 index bcb78581b..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/list_lobbies_response.ex +++ /dev/null @@ -1,16 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.ListLobbiesResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate({:error, String.t()} | T.lobby()) :: T.tachyon_response() - def generate({:error, reason}) do - {"system/error/response", :error, reason} - end - - def generate(lobbies) do - {"lobby/list_lobbies/response", :success, %{"lobbies" => lobbies}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/received_join_request_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/received_join_request_response.ex deleted file mode 100644 index a4820cad2..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/received_join_request_response.ex +++ /dev/null @@ -1,20 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.ReceivedJoinRequestResponseResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(map()) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate(%{response: :accept, lobby_id: lobby_id}) do - {"lobby/receivedJoinRequestResponse/response", :success, - %{"result" => "accept", "lobby_id" => lobby_id}} - end - - def generate(%{response: :deny, lobby_id: lobby_id, reason: reason}) do - {"lobby/receivedJoinRequestResponse/response", :success, - %{"result" => "deny", "lobby_id" => lobby_id, "reason" => reason}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/remove_user_client_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/remove_user_client_response.ex deleted file mode 100644 index 22ca40b8e..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/remove_user_client_response.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.RemoveUserClientResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(T.userid(), T.lobby_id()) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate(userid, lobby_id) when is_integer(userid) and is_integer(lobby_id) do - {"lobby/removeUserClient/response", :success, - %{ - "lobby_id" => lobby_id, - "userid" => userid - }} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/update_status_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/update_status_response.ex deleted file mode 100644 index 69a6c6d6c..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby/update_status_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Lobby.UpdateStatusResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate() do - {"lobby/updateStatus/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/said_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/said_response.ex deleted file mode 100644 index dc41e5653..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/said_response.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyChat.SaidResponse do - @moduledoc """ - - """ - alias Teiserver.Data.Types, as: T - - @spec generate(T.userid(), T.lobby_id(), String.t()) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate(userid, lobby_id, message) when is_integer(userid) and is_integer(lobby_id) do - {"lobbyChat/said/response", :success, - %{ - "userid" => userid, - "lobby_id" => lobby_id, - "message" => message - }} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/say_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/say_response.ex deleted file mode 100644 index 63dc5ee36..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_chat/say_response.ex +++ /dev/null @@ -1,22 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyChat.SayResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(true | false | :no_lobby) :: - {T.tachyon_command(), :success, T.tachyon_object()} - | {T.tachyon_command(), T.error_pair()} - def generate(:no_lobby) do - {"system/error/response", {:error, "Not a member of a lobby"}} - end - - def generate(false) do - {"system/error/response", {:error, "Not allowed to chat in this lobby"}} - end - - def generate(true) do - {"lobbyChat/say/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/add_bot_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/add_bot_response.ex deleted file mode 100644 index 22d3e18f8..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/add_bot_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.AddBotResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/add_bot/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/close_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/close_response.ex deleted file mode 100644 index b50cb2767..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/close_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.CloseResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/close/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/create_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/create_response.ex deleted file mode 100644 index c15b53d39..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/create_response.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.CreateResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Phoenix.PubSub - alias Teiserver.Data.Types, as: T - - @spec generate({:error, String.t()} | T.lobby()) :: {T.tachyon_command(), T.tachyon_object()} - def generate({:error, reason}) do - {"lobbyHost/create/request", :error, reason} - end - - def generate({:ok, lobby}) do - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_host_message:#{lobby.id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby.id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby.id}") - - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_host_message:#{lobby.id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby.id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby.id}") - - {"lobbyHost/create/response", :success, lobby} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/end_battle_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/end_battle_response.ex deleted file mode 100644 index 0af6a0926..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/end_battle_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.EndBattleResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/end_battle/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/join_request_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/join_request_response.ex deleted file mode 100644 index 45d7e4167..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/join_request_response.ex +++ /dev/null @@ -1,15 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.JoinRequestReponse do - @moduledoc false - - alias Teiserver.Data.Types, as: T - - @spec generate(T.userid(), T.lobby_id()) :: {T.tachyon_command(), T.tachyon_object()} - def generate(userid, lobby_id) do - object = %{ - userid: userid, - lobby_id: lobby_id - } - - {"lobbyHost/joinRequest/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/remove_bot_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/remove_bot_response.ex deleted file mode 100644 index 147bfa11f..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/remove_bot_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.RemoveBotResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/remove_bot/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/respond_to_join_request_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/respond_to_join_request_response.ex deleted file mode 100644 index 9e07b526d..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/respond_to_join_request_response.ex +++ /dev/null @@ -1,10 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.RespondToJoinRequestResponse do - @moduledoc false - - alias Teiserver.Data.Types, as: T - - @spec generate(atom) :: {T.tachyon_command(), T.tachyon_object()} - def generate(:ok) do - {"lobbyHost/respondToJoinRequest/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/start_battle_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/start_battle_response.ex deleted file mode 100644 index 4fe578044..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/start_battle_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.StartBattleResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/start_battle/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/update_bot_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/update_bot_response.ex deleted file mode 100644 index b3e87c232..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/update_bot_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.UpdateBotResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/update_bot/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/updated_status_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/updated_status_response.ex deleted file mode 100644 index 2a7c77943..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/lobby_host/updated_status_response.ex +++ /dev/null @@ -1,14 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.LobbyHost.UpdatedStatusResponse do - @moduledoc """ - Updated status response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/lobby_host.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate() :: {T.tachyon_command(), T.tachyon_object()} - def generate() do - object = %{} - - {"lobbyHost/updated_status/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/system/disconnect_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/system/disconnect_response.ex deleted file mode 100644 index 838dcdd19..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/system/disconnect_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.System.DisconnectResponse do - @moduledoc """ - Error response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/system.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(String.t()) :: {T.tachyon_command(), T.tachyon_object()} - def generate(_reason) do - {"disconnect", :success, nil} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/system/error_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/system/error_response.ex deleted file mode 100644 index 377294234..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/system/error_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.System.ErrorResponse do - @moduledoc """ - Error response - https://github.com/beyond-all-reason/tachyon/blob/master/src/schema/system.ts - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(String.t()) :: {T.tachyon_command(), T.tachyon_object()} - def generate(reason) do - {"system/error/response", :error, reason} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/system/ping_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/system/ping_response.ex deleted file mode 100644 index 404740fda..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/system/ping_response.ex +++ /dev/null @@ -1,15 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.System.PingResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(T.tachyon_conn()) :: - {T.tachyon_command(), T.tachyon_status(), T.tachyon_object()} - def generate(_conn) do - object = %{} - - {"system/ping/response", :success, object} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/event_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/event_response.ex deleted file mode 100644 index 7ce44f4fb..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/event_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Telemetry.EventResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(atom) :: {T.tachyon_command(), T.tachyon_status(), T.tachyon_object()} - def generate(:ok) do - {"telemetry/event/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/property_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/property_response.ex deleted file mode 100644 index 2cc2c28b5..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/telemetry/property_response.ex +++ /dev/null @@ -1,12 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.Telemetry.PropertyResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - - @spec generate(atom) :: {T.tachyon_command(), T.tachyon_status(), T.tachyon_object()} - def generate(:ok) do - {"telemetry/property/response", :success, %{}} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/responses/user/updated_user_client_response.ex b/lib/teiserver/protocols/tachyon_json_ws/responses/user/updated_user_client_response.ex deleted file mode 100644 index 7f7f49c81..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/responses/user/updated_user_client_response.ex +++ /dev/null @@ -1,34 +0,0 @@ -defmodule Teiserver.Tachyon.Responses.User.UpdatedUserClientResponse do - @moduledoc """ - - """ - - alias Teiserver.Data.Types, as: T - alias Teiserver.Tachyon.Converters - - @spec generate(map()) :: {T.tachyon_command(), T.tachyon_object()} - def generate(client) do - object = %{ - "userid" => client.userid, - "status" => Converters.convert(client, :client) - } - - {"user/UpdatedUserClient/response", :success, - %{ - "userClient" => object - }} - end - - @spec generate(T.userid(), map()) :: {T.tachyon_command(), T.tachyon_object()} - def generate(userid, partial_client) do - object = %{ - "userid" => userid, - "status" => Converters.convert(partial_client, :client) - } - - {"user/UpdatedUserClient/response", :success, - %{ - "userClient" => object - }} - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/socket/socket_lib.ex b/lib/teiserver/protocols/tachyon_json_ws/socket/socket_lib.ex deleted file mode 100644 index 66fa48d7b..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/socket/socket_lib.ex +++ /dev/null @@ -1,8 +0,0 @@ -defmodule Teiserver.Tachyon.SocketLib do - @moduledoc """ - - """ - - def error_response() do - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/tachyon_schema.ex b/lib/teiserver/protocols/tachyon_json_ws/tachyon_schema.ex deleted file mode 100644 index 642352cb6..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/tachyon_schema.ex +++ /dev/null @@ -1,44 +0,0 @@ -defmodule Teiserver.Tachyon.Schema do - @moduledoc """ - - """ - - @spec load_schemas :: {:ok, list} - def load_schemas() do - schemas = - Application.get_env(:teiserver, Teiserver)[:tachyon_schema_path] - |> Path.wildcard() - |> Enum.map(fn file_path -> - contents = - file_path - |> File.read!() - |> Jason.decode!() - - command = - file_path - |> Path.split() - |> Enum.reverse() - |> Enum.take(3) - |> Enum.reverse() - |> Enum.join("/") - |> String.replace(".json", "") - - schema = JsonXema.new(contents) - - Teiserver.store_put(:tachyon_schemas, command, schema) - command - end) - - {:ok, schemas} - end - - @spec validate!(map) :: :ok - def validate!(%{"command" => command} = object) do - schema = get_schema(command) - JsonXema.validate!(schema, object) - end - - defp get_schema(command) do - ConCache.get(:tachyon_schemas, command) - end -end diff --git a/lib/teiserver/protocols/tachyon_json_ws/tachyon_socket.ex b/lib/teiserver/protocols/tachyon_json_ws/tachyon_socket.ex deleted file mode 100644 index d455e9234..000000000 --- a/lib/teiserver/protocols/tachyon_json_ws/tachyon_socket.ex +++ /dev/null @@ -1,347 +0,0 @@ -defmodule Teiserver.Tachyon.TachyonSocket do - @behaviour Phoenix.Socket.Transport - - require Logger - alias Phoenix.PubSub - alias Teiserver.Config - alias Teiserver.Account - alias Teiserver.Tachyon.{CommandDispatch, MessageHandlers} - alias Teiserver.Tachyon.Responses.System.ErrorResponse - # alias Teiserver.Tachyon.Socket.PubsubHandlers - alias Teiserver.Data.Types, as: T - - @spec child_spec(any) :: :ignore - def child_spec(_opts) do - # We won't spawn any process, so let's return a dummy task - # %{id: __MODULE__, start: {Task, :start_link, [fn -> :ok end]}, restart: :transient} - :ignore - end - - @spec connect(map()) :: - {:ok, T.tachyon_ws_state()} | {:error, atom | String.t()} - def connect( - %{ - params: %{ - "token" => token_value, - "application_hash" => _, - "application_name" => _, - "application_version" => _ - } - } = state - ) do - case Account.get_user_token_by_value(token_value) do - nil -> - {:error, :no_user} - - %{user: _user, expires: _expires} = token -> - case login(token, state) do - {:ok, conn} -> - {:ok, Map.put(state, :conn, conn)} - - v -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line} - Login failure with token: #{inspect(v)}\n" - ) - - {:error, :failed_login} - end - - value -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line} - No handler for value of #{inspect(value)}" - ) - - {:error, :unexpected_value} - end - end - - def connect(%{params: params}) do - missing = - ~w(token application_hash application_name application_version) - |> Enum.reject(fn key -> Map.has_key?(params, key) end) - |> Enum.join(", ") - - {:error, "missing_params: #{missing}"} - end - - @spec init(T.tachyon_ws_state()) :: {:ok, T.tachyon_ws_state()} - def init(%{conn: %{userid: userid}} = state) do - :timer.send_after(1500, :connect_to_client) - - Logger.metadata(request_id: "TachyonWSServer##{userid}") - :ok = PubSub.subscribe(Teiserver.PubSub, "teiserver_client_messages:#{userid}") - :ok = PubSub.subscribe(Teiserver.PubSub, "teiserver_server") - - {:ok, state} - end - - # Example of a good whoami request - # {"command": "account/whoAmI/request", "data": {}} - - # @spec handle_in({atom, any}, T.tachyon_ws_state()) :: {:ok, T.tachyon_ws_state()} | {:reply, :ok, {:text, String.t()}, T.tachyon_ws_state()} - def handle_in({text, _opts}, %{conn: conn} = state) do - with {:ok, raw_json} <- decompress_message(text, conn), - {:ok, wrapped_object} <- decode_message(raw_json, conn), - {:ok, resp, new_conn} <- handle_command(wrapped_object, conn) do - if resp != nil do - {:reply, :ok, {:text, resp |> Jason.encode!()}, %{state | conn: new_conn}} - else - {:ok, state} - end - else - {:json_error, error_message} -> - {:reply, :ok, {:text, %{error: error_message} |> Jason.encode!()}, state} - end - end - - # We currently don't have compression but if/when we do it will be tracked in the conn - # so it goes here - defp decompress_message(text, _conn) do - {:ok, text} - end - - @spec decode_message(String.t(), T.tachyon_conn()) :: {:ok, map()} | {:json_error, String.t()} - defp decode_message(text, _conn) do - case Jason.decode(text) do - {:ok, msg} -> {:ok, msg} - {:error, err} -> {:json_error, "Decode error: #{inspect(err)}"} - end - end - - defp handle_command(wrapper, conn) do - object = wrapper["data"] - meta = Map.drop(wrapper, ["data"]) - - {dispatch_response, new_conn} = - try do - CommandDispatch.dispatch(conn, object, meta) - rescue - e in FunctionClauseError -> - handle_error(e, __STACKTRACE__, conn) - - send(self(), :disconnect_on_error) - - response = - ErrorResponse.generate("Server FunctionClauseError for command #{meta["command"]}") - - {response, conn} - - # e in RuntimeError -> - # raise e - - e -> - handle_error(e, __STACKTRACE__, conn) - - send(self(), :disconnect_on_error) - - response = - ErrorResponse.generate("Internal server error for command #{meta["command"]}") - - {response, conn} - end - - response = - case dispatch_response do - {_command, :success, nil} -> - nil - - {command, :success, data} -> - %{ - "command" => command, - "status" => "success", - "data" => data - } - - {command, :error, reason} -> - %{ - "command" => command, - "status" => "failure", - "reason" => reason - } - - {command, {:error, reason}} -> - %{ - "command" => command, - "status" => "failure", - "reason" => reason - } - end - - # Currently not able to validate errors so leaving it out - # if response != nil do - # Teiserver.Tachyon.Schema.validate!(response) - # end - - {:ok, response, new_conn} - end - - @spec handle_info(any, T.tachyon_ws_state()) :: - {:reply, :ok, {:binary, binary}, T.tachyon_ws_state()} - def handle_info(:connect_to_client, state) do - Account.cast_client(state.conn.userid, {:update_tcp_pid, self()}) - {:ok, state} - end - - # Holdover from Spring stuff, discard message for now - def handle_info({:request_user_join_lobby, _}, state) do - {:ok, state} - end - - def handle_info(%{channel: channel} = msg, state) do - # First we find the module to handle this message, we have one module per channel - module = - case channel do - "teiserver_lobby_host_message" <> _ -> - MessageHandlers.LobbyHostMessageHandlers - - "teiserver_client_messages" <> _ -> - MessageHandlers.ClientMessageHandlers - - "teiserver_lobby_updates" <> _ -> - MessageHandlers.LobbyUpdateMessageHandlers - - "teiserver_lobby_chat" <> _ -> - MessageHandlers.LobbyChatMessageHandlers - - _ -> - raise "No handler for messages to channel #{msg.channel}" - end - - # Now we get the module to try and handle it - try do - case module.handle(msg, state.conn) do - nil -> - {:ok, state} - - {:ok, new_conn} -> - {:ok, %{state | conn: new_conn}} - - {:ok, resp, new_conn} -> - {:reply, :ok, {:text, resp |> Jason.encode!()}, %{state | conn: new_conn}} - end - rescue - e -> - handle_error(e, __STACKTRACE__, state.conn) - - send(self(), :disconnect_on_error) - - {command, _, reason} = - ErrorResponse.generate("Internal server error for internal channel #{channel}") - - response = %{ - "command" => command, - "status" => "failure", - "reason" => reason - } - - {:reply, :ok, {:text, response |> Jason.encode!()}, state} - end - end - - # We have disconnect on error so we can later more easily make it so people can stay connected on error if needed for some reason - def handle_info(:disconnect_on_error, state) do - {:stop, :disconnected, state} - end - - def handle_info(:disconnect, state) do - {:stop, :disconnected, state} - end - - def handle_info(%{} = msg, state) do - raise msg - IO.puts("") - IO.inspect(msg, label: "ws handle_info") - IO.puts("") - - # Use this to not send anything - {:ok, state} - - # This will send stuff - # {:reply, :ok, {:binary, <<111>>}, state} - end - - defp handle_error(error, stacktrace, _conn) do - spawn(fn -> - reraise error, stacktrace - end) - - # Logger.error("EEEEE") - - # reraise error, stacktrace - end - - @spec terminate(any, any) :: :ok - def terminate({:error, :closed}, %{conn: %{userid: userid}} = _state) do - Teiserver.Client.disconnect(userid, "connection closed by client") - :ok - end - - def terminate(reason, %{conn: %{userid: userid}} = _state) do - Teiserver.Client.disconnect(userid, "ws terminate - reason: #{inspect(reason)}") - :ok - end - - def terminate(_reason, _state) do - :ok - end - - defp login(%{user: _user, expires: _expires} = token, state) do - response = Teiserver.CacheUser.login_from_token(token, state) - - case response do - {:ok, user} -> - {:ok, new_conn(user)} - - {:error, reason} -> - {:error, reason} - - {:error, reason, _userid} -> - {:error, reason} - end - end - - @spec new_conn(Teiserver.Account.User.t()) :: map() - defp new_conn(user) do - exempt_from_cmd_throttle = true - - %{ - # Client state - userid: user.id, - username: user.name, - queues: [], - lobby_id: nil, - lobby_host: false, - party_id: nil, - party_role: nil, - exempt_from_cmd_throttle: exempt_from_cmd_throttle, - cmd_timestamps: [], - error_handle: :raise, - - # Caching app configs - flood_rate_limit_count: - Config.get_site_config_cache("teiserver.Tachyon flood rate limit count"), - floot_rate_window_size: - Config.get_site_config_cache("teiserver.Tachyon flood rate window size") - } - end - - def handle_error(conn, {:missing_params, param}), - do: Plug.Conn.send_resp(conn, 400, "Missing parameter(s): #{param}") - - def handle_error(conn, "missing_params: " <> param), - do: Plug.Conn.send_resp(conn, 400, "Missing parameter(s): #{param}") - - def handle_error(conn, :no_user), do: Plug.Conn.send_resp(conn, 401, "Unauthorized") - def handle_error(conn, :failed_login), do: Plug.Conn.send_resp(conn, 403, "Forbidden") - def handle_error(conn, :rate_limit), do: Plug.Conn.send_resp(conn, 429, "Too many requests") - - def handle_error(conn, :unexpected_value), - do: Plug.Conn.send_resp(conn, 500, "Internal server error") - - # Uncomment when we have an error we need to print out - # def handle_error(conn, error) do - # raise "Unexpected error of #{inspect(error)}" - - # Plug.Conn.send_resp(conn, 500, "Internal server error") - # end -end diff --git a/lib/teiserver/protocols/tachyon_lib.ex b/lib/teiserver/protocols/tachyon_lib.ex deleted file mode 100644 index 3ef48e818..000000000 --- a/lib/teiserver/protocols/tachyon_lib.ex +++ /dev/null @@ -1,116 +0,0 @@ -defmodule Teiserver.Protocols.TachyonLib do - require Logger - - @spec get_modules :: {module(), module()} - def get_modules(), do: get_modules("v1") - - @spec get_modules(String.t()) :: {module(), module()} - def get_modules("dev") do - {Teiserver.Protocols.Tachyon.V1.TachyonIn, Teiserver.Protocols.Tachyon.V1.TachyonOut} - end - - def get_modules("v1") do - {Teiserver.Protocols.Tachyon.V1.TachyonIn, Teiserver.Protocols.Tachyon.V1.TachyonOut} - end - - @spec format_log(String.t()) :: String.t() - def format_log(s) do - Kernel.inspect(s) - end - - @spec encode(List.t() | Map.t()) :: String.t() - def encode(data) do - case Jason.encode(data) do - {:ok, encoded_data} -> - encoded_data - |> :zlib.gzip() - |> Base.encode64() - - {:error, err} -> - Logger.error( - "Tachyon encode error: #{Kernel.inspect(err)}\ndata: #{Kernel.inspect(data)}" - ) - - %{ - result: "s.system.server_protocol_error", - error: "JSON encode" - } - - "" - |> Jason.encode!() - |> :zlib.gzip() - |> Base.encode64() - end - end - - @spec decode(String.t() | :timeout) :: {:ok, List.t() | Map.t()} | {:error, :bad_json} - def decode(:timeout), do: {:ok, nil} - def decode(""), do: {:ok, nil} - - def decode(data) do - with {:ok, decoded64} <- Base.decode64(data |> String.trim()), - {:ok, unzipped} <- unzip(decoded64), - {:ok, object} <- Jason.decode(unzipped) do - {:ok, object} - else - :error -> - # Previously got an error with data 'OK cmd=TACHYON' which suggests - # it was still in Spring mode - Logger.warning("Base64 error, given '#{data}'") - {:error, :base64_decode} - - {:error, :gzip_decompress} -> - Logger.warning("Gzip error, given '#{data}'") - {:error, :gzip_decompress} - - {:error, %Jason.DecodeError{}} -> - {:error, :bad_json} - end - end - - defp unzip(data) do - try do - result = :zlib.gunzip(data) - {:ok, result} - rescue - _ -> - {:error, :gzip_decompress} - end - end - - @spec decode!(String.t() | :timeout) :: List.t() | Map.t() - def decode!(data) do - case decode(data) do - {:ok, result} -> - result - - {:error, reason} -> - raise "Tachyon decode! error: #{reason}, data: #{data}" - end - end - - @spec query(List.t(), atom | nil, any) :: List.t() - def query(list, nil, _), do: list - def query(list, _, nil), do: list - - def query(list, field, value) when is_atom(field) do - list - |> Enum.filter(fn item -> Map.get(item, field) == value end) - end - - @spec query_in(List.t(), atom | nil, List.t()) :: List.t() - def query_in(list, nil, _), do: list - def query_in(list, _, nil), do: list - - def query_in(list, field, value) when is_atom(field) do - list - |> Enum.filter(fn item -> Enum.member?(value, Map.get(item, field)) end) - end - - # def query(list, _, func) when is_function(func) do - # list - # |> Enum.filter(fn item -> - # func.(item) - # end) - # end -end diff --git a/lib/teiserver/protocols/tachyon_v1/auth_in.ex b/lib/teiserver/protocols/tachyon_v1/auth_in.ex deleted file mode 100644 index 9e089ec96..000000000 --- a/lib/teiserver/protocols/tachyon_v1/auth_in.ex +++ /dev/null @@ -1,160 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.AuthIn do - alias Teiserver.{CacheUser, Client, Account} - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.Account.LoginThrottleServer - alias Teiserver.Data.Types, as: T - - @spec do_handle(String.t(), Map.t(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - def do_handle("get_token", _, %{transport: :ranch_tcp} = state) do - reply(:auth, :user_token, {:failure, "Non-secured connection"}, state) - end - - def do_handle("get_token", %{"email" => email, "password" => plain_text_password}, state) do - case CacheUser.get_user_by_email(email) do - nil -> - reply(:auth, :user_token, {:failure, "Incorrect credentials"}, state) - - user -> - # Are they an md5 conversion user? - case user.spring_password do - true -> - # Yes, we can test and update their password accordingly! - md5_password = CacheUser.spring_md5_password(plain_text_password) - - case CacheUser.test_password(md5_password, user.password_hash) do - true -> - # Update the db user then the cached user - db_user = Account.get_user!(user.id) - Teiserver.Account.update_user(db_user, %{"password" => plain_text_password}) - CacheUser.recache_user(user.id) - CacheUser.update_user(%{user | spring_password: false}, persist: true) - - token = CacheUser.create_token(user) - reply(:auth, :user_token, {:success, token}, state) - - false -> - reply(:auth, :user_token, {:failure, "Invalid credentials."}, state) - end - - false -> - db_user = Account.get_user!(user.id) - - case Teiserver.Account.User.verify_password(plain_text_password, db_user.password) do - true -> - token = CacheUser.create_token(user) - reply(:auth, :user_token, {:success, token}, state) - - false -> - reply(:auth, :user_token, {:failure, "Invalid credentials"}, state) - end - end - end - end - - def do_handle( - "login", - %{ - "token" => token, - "lobby_name" => lobby_name, - "lobby_version" => lobby_version, - "lobby_hash" => lobby_hash - }, - state - ) do - response = CacheUser.try_login(token, state.ip, "#{lobby_name} #{lobby_version}", lobby_hash) - - case response do - {:ok, user} -> - send(self(), {:action, {:login_accepted, user}}) - reply(:auth, :login, {:success, user}, state) - - {:error, "Queued", userid, lobby, lobby_hash} -> - reply(:auth, :login_queued, nil, state) - - if String.starts_with?(lobby, "BAR Lobby") do - my_pid = self() - - spawn(fn -> - :timer.sleep(2000) - LoginThrottleServer.heartbeat(my_pid, userid) - end) - - spawn(fn -> - :timer.sleep(4000) - LoginThrottleServer.heartbeat(my_pid, userid) - end) - - spawn(fn -> - :timer.sleep(6000) - LoginThrottleServer.heartbeat(my_pid, userid) - end) - - spawn(fn -> - :timer.sleep(8000) - LoginThrottleServer.heartbeat(my_pid, userid) - end) - end - - Map.merge(state, %{ - lobby: lobby, - lobby_hash: lobby_hash, - queued_userid: userid - }) - - {:error, "Unverified", _userid} -> - reply(:auth, :user_agreement, nil, state) - - {:error, reason} -> - reply(:auth, :login, {:failure, reason}, state) - end - end - - def do_handle("verify", %{"token" => token, "code" => code}, state) do - user = CacheUser.get_user_by_token(token) - - case user do - nil -> - reply(:auth, :verify, {:failure, "bad token"}, state) - - _ -> - correct_code = Account.get_user_stat_data(user.id)["verification_code"] - - if correct_code == code do - user = CacheUser.verify_user(user) - reply(:auth, :verify, {:success, user}, state) - else - reply(:auth, :verify, {:failure, "bad code"}, state) - end - end - end - - def do_handle("disconnect", _data, state) do - Client.disconnect(state.userid, "Tachyon auth.disconnect") - send(self(), :terminate) - state - end - - def do_handle( - "register", - %{"username" => username, "email" => email, "password" => password}, - state - ) do - response = CacheUser.register_user(username, email, password) - reply(:auth, :register, response, state) - end - - def do_handle(cmd, data, state) do - # It's possible there is a password in this data, if there is we need to remove it - data = if Map.has_key?(data, "password"), do: Map.put(data, "password", "*******"), else: data - - reply( - :system, - :error, - %{ - location: "auth.handle", - error: "No match for cmd: '#{cmd}' with data '#{Kernel.inspect(data)}'" - }, - state - ) - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/auth_out.ex b/lib/teiserver/protocols/tachyon_v1/auth_out.ex deleted file mode 100644 index 88b708a61..000000000 --- a/lib/teiserver/protocols/tachyon_v1/auth_out.ex +++ /dev/null @@ -1,101 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.AuthOut do - alias Teiserver.Protocols.Tachyon.V1.Tachyon - - @spec do_reply(atom(), any) :: Map.t() - - ########### - # Tokens - def do_reply(:user_token, {:success, token}) do - %{ - "cmd" => "s.auth.get_token", - "result" => "success", - "token" => token - } - end - - def do_reply(:user_token, {:failure, reason}) do - %{ - "cmd" => "s.auth.get_token", - "result" => "failure", - "reason" => reason - } - end - - ########### - # Agreement - def do_reply(:user_agreement, nil) do - %{ - "cmd" => "s.auth.login", - "result" => "unverified", - "agreement" => Application.get_env(:teiserver, Teiserver)[:user_agreement] - } - end - - ########### - # Verify - def do_reply(:verify, {:failure, reason}) do - %{ - "cmd" => "s.auth.verify", - "result" => "failure", - "reason" => reason - } - end - - def do_reply(:verify, {:success, user}) do - %{ - "cmd" => "s.auth.verify", - "result" => "success", - "user" => Tachyon.convert_object(user, :user_extended_icons) - } - end - - ########### - # Login - def do_reply(:login_queued, _) do - %{ - "cmd" => "s.auth.login", - "result" => "queued" - } - end - - def do_reply(:login, {:failure, reason}) do - %{ - "cmd" => "s.auth.login", - "result" => "failure", - "reason" => reason - } - end - - def do_reply(:login, {:success, user}) do - %{ - "cmd" => "s.auth.login", - "result" => "success", - "user" => Tachyon.convert_object(user, :user_extended_icons) - } - end - - ######### - # Register - def do_reply(:register, :success) do - %{ - "cmd" => "s.auth.register", - "result" => "success" - } - end - - def do_reply(:register, {:failure, reason}) do - %{ - "cmd" => "s.auth.register", - "result" => "failure", - "reason" => reason - } - end - - def do_reply(:register, {:error, reason}) do - %{ - "cmd" => "s.auth.register", - "result" => "failure", - "reason" => reason - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/client_in.ex b/lib/teiserver/protocols/tachyon_v1/client_in.ex deleted file mode 100644 index 8b839b967..000000000 --- a/lib/teiserver/protocols/tachyon_v1/client_in.ex +++ /dev/null @@ -1,28 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.ClientIn do - alias Teiserver.{Client} - alias Teiserver.Protocols.Tachyon.V1.Tachyon - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.Data.Types, as: T - - @spec do_handle(String.t(), Map.t(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - def do_handle("list_clients_from_ids", %{"id_list" => id_list}, state) do - clients = - Client.get_clients(id_list) - |> Enum.filter(fn c -> c != nil end) - |> Enum.map(fn c -> Tachyon.convert_object(c, :client) end) - - reply(:client, :client_list, clients, state) - end - - def do_handle(cmd, data, state) do - reply( - :system, - :error, - %{ - location: "auth.handle", - error: "No match for cmd: '#{cmd}' with data '#{Kernel.inspect(data)}'" - }, - state - ) - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/client_out.ex b/lib/teiserver/protocols/tachyon_v1/client_out.ex deleted file mode 100644 index 0eea11009..000000000 --- a/lib/teiserver/protocols/tachyon_v1/client_out.ex +++ /dev/null @@ -1,55 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.ClientOut do - @spec do_reply(atom(), any) :: Map.t() - def do_reply(:client_list, clients) do - %{ - cmd: "s.client.client_list", - clients: clients - } - end - - def do_reply(:connected, userid) do - %{ - cmd: "s.client.connected", - userid: userid - } - end - - def do_reply(:disconnected, userid) do - %{ - cmd: "s.client.disconnected", - userid: userid - } - end - - def do_reply(:added_to_party, {userid, party_id}) do - %{ - cmd: "s.client.added_to_party", - userid: userid, - party_id: party_id - } - end - - def do_reply(:left_party, {userid, party_id}) do - %{ - cmd: "s.client.left_party", - userid: userid, - party_id: party_id - } - end - - def do_reply(:added_to_lobby, {userid, lobby_id}) do - %{ - cmd: "s.client.added_to_lobby", - userid: userid, - lobby_id: lobby_id - } - end - - def do_reply(:left_lobby, {userid, lobby_id}) do - %{ - cmd: "s.client.left_lobby", - userid: userid, - lobby_id: lobby_id - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/communication_in.ex b/lib/teiserver/protocols/tachyon_v1/communication_in.ex deleted file mode 100644 index e80786548..000000000 --- a/lib/teiserver/protocols/tachyon_v1/communication_in.ex +++ /dev/null @@ -1,24 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.CommunicationIn do - alias Teiserver.{Account, CacheUser} - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - - @spec do_handle(String.t(), Map.t(), Map.t()) :: Map.t() - def do_handle("get_latest_game_news", _cmd, state) do - state - end - - def do_handle( - "send_direct_message", - %{"recipient_id" => recipient_id, "message" => message}, - state - ) do - cond do - not Account.client_exists?(recipient_id) -> - reply(:communication, :send_direct_message, {:failure, "Recipient offline"}, state) - - true -> - CacheUser.send_direct_message(state.userid, recipient_id, message) - reply(:communication, :send_direct_message, :success, state) - end - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/communication_out.ex b/lib/teiserver/protocols/tachyon_v1/communication_out.ex deleted file mode 100644 index 9b9e7fb4a..000000000 --- a/lib/teiserver/protocols/tachyon_v1/communication_out.ex +++ /dev/null @@ -1,43 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.CommunicationOut do - # alias Teiserver.Protocols.Tachyon.V1.Tachyon - require Logger - - @spec do_reply(atom(), any) :: Map.t() - - ########### - # Direct messages - def do_reply(:direct_message, {sender_id, msg}) do - Logger.warning( - "Using :direct_message instead of :received_direct_message in V1.CommunicationOut" - ) - - %{ - "cmd" => "s.communication.received_direct_message", - "sender_id" => sender_id, - "message" => msg |> Enum.join("\n") - } - end - - def do_reply(:received_direct_message, {sender_id, msg}) do - %{ - "cmd" => "s.communication.received_direct_message", - "sender_id" => sender_id, - "message" => msg |> Enum.join("\n") - } - end - - def do_reply(:send_direct_message, :success) do - %{ - "cmd" => "s.communication.send_direct_message", - "result" => "success" - } - end - - def do_reply(:send_direct_message, {:failure, reason}) do - %{ - "cmd" => "s.communication.send_direct_message", - "result" => "failure", - "reason" => reason - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/config_in.ex b/lib/teiserver/protocols/tachyon_v1/config_in.ex deleted file mode 100644 index c45134c29..000000000 --- a/lib/teiserver/protocols/tachyon_v1/config_in.ex +++ /dev/null @@ -1,110 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.ConfigIn do - alias Teiserver.Config - alias Teiserver.{Account} - # alias Teiserver.Protocols.Tachyon.V1.Tachyon - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.Data.Types, as: T - - @spec do_handle(String.t(), Map.t(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - - # Game config - def do_handle("game_set", %{"configs" => configs}, state) do - configs = - configs - |> Map.new(fn {key, value} -> {"game_config.#{key}", value} end) - - Account.update_user_stat(state.userid, configs) - - state - end - - def do_handle("game_get", %{"keys" => keys}, state) do - keys = - keys - |> Enum.map(fn key -> "game_config.#{key}" end) - - configs = - Account.get_user_stat_data(state.userid) - |> Enum.filter(fn {key, _value} -> - Enum.member?(keys, key) - end) - |> Map.new(fn {"game_config." <> key, value} -> - {key, value} - end) - - reply(:config, :game_get, configs, state) - end - - def do_handle("game_delete", %{"keys" => keys}, state) do - keys = - keys - |> Enum.map(fn key -> "game_config.#{key}" end) - - Account.delete_user_stat_keys(state.userid, keys) - - state - end - - # User config - def do_handle("list_user_types", _, state) do - types = - Config.get_user_config_types() - |> Enum.filter(fn {_key, type} -> - type.permissions == [] or type.permissions == ["account"] - end) - |> Enum.map(fn {_key, type} -> type end) - - reply(:config, :list_user_types, types, state) - end - - def do_handle("user_set", %{"configs" => configs}, state) do - configs - |> Enum.filter(fn {key, _value} -> - type = Config.get_user_config_type(key) - - cond do - type == nil -> false - type.permissions == [] -> true - type.permissions == ["account"] -> true - true -> false - end - end) - |> Enum.each(fn {key, value} -> - Config.set_user_config(state.userid, key, value) - end) - - state - end - - def do_handle("user_get", %{"keys" => keys}, state) do - configs = - keys - |> Enum.filter(fn key -> - type = Config.get_user_config_type(key) - - cond do - type == nil -> false - type.permissions == [] -> true - type.permissions == ["teiserver"] -> true - true -> false - end - end) - |> Map.new(fn key -> - {key, Config.get_user_config_cache(state.userid, key)} - end) - - reply(:config, :user_get, configs, state) - end - - def do_handle(cmd, data, state) do - reply( - :system, - :error, - %{ - location: "auth.handle", - error: "No match for cmd: '#{cmd}' with data '#{Kernel.inspect(data)}'" - }, - state - ) - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/config_out.ex b/lib/teiserver/protocols/tachyon_v1/config_out.ex deleted file mode 100644 index d7eee2e19..000000000 --- a/lib/teiserver/protocols/tachyon_v1/config_out.ex +++ /dev/null @@ -1,33 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.ConfigOut do - alias Teiserver.Protocols.Tachyon.V1.Tachyon - require Logger - - @spec do_reply(atom(), any) :: Map.t() - - ########### - # Game configs - def do_reply(:game_get, configs) do - %{ - "cmd" => "s.config.game_get", - "configs" => configs - } - end - - ########### - # User configs - def do_reply(:list_user_types, types) do - %{ - "cmd" => "s.config.list_user_types", - "types" => - types - |> Enum.map(fn type -> Tachyon.convert_object(type, :user_config_type) end) - } - end - - def do_reply(:user_get, configs) do - %{ - "cmd" => "s.config.user_get", - "configs" => configs - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/lobby_chat_out.ex b/lib/teiserver/protocols/tachyon_v1/lobby_chat_out.ex deleted file mode 100644 index 7e989cb59..000000000 --- a/lib/teiserver/protocols/tachyon_v1/lobby_chat_out.ex +++ /dev/null @@ -1,23 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.LobbyChatOut do - @spec do_reply(atom, any) :: map() - - ########### - # Messages - def do_reply(:say, {lobby_id, sender_id, message}) do - %{ - "cmd" => "s.lobby.say", - "lobby_id" => lobby_id, - "sender_id" => sender_id, - "message" => message - } - end - - def do_reply(:announce, {lobby_id, sender_id, message}) do - %{ - "cmd" => "s.lobby.announce", - "lobby_id" => lobby_id, - "sender_id" => sender_id, - "message" => message - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/lobby_host_in.ex b/lib/teiserver/protocols/tachyon_v1/lobby_host_in.ex deleted file mode 100644 index a6a4b4fc5..000000000 --- a/lib/teiserver/protocols/tachyon_v1/lobby_host_in.ex +++ /dev/null @@ -1,52 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.LobbyHostIn do - alias Teiserver.Lobby - alias Teiserver.{Coordinator} - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - import Teiserver.Helper.NumberHelper, only: [int_parse: 1] - alias Teiserver.Data.Types, as: T - - @spec do_handle(String.t(), Map.t(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - def do_handle("update_host_status", _, %{userid: nil} = state), - do: reply(:system, :nouser, nil, state) - - def do_handle("update_host_status", _, %{lobby_id: nil} = state), - do: reply(:system, :nolobby, nil, state) - - def do_handle("update_host_status", new_status, state) do - host_data = - new_status - |> Map.take(~w(boss teamsize teamcount)) - |> Map.new(fn {k, v} -> {String.to_atom("host_" <> k), int_parse(v)} end) - - if Lobby.allow?(state.userid, :update_host_status, state.lobby_id) do - Coordinator.cast_consul(state.lobby_id, {:host_update, state.userid, host_data}) - end - - state - end - - def do_handle("respond_to_join_request", data, %{lobby_id: lobby_id} = state) do - userid = int_parse(data["userid"]) - - case data["response"] do - "approve" -> - Lobby.accept_join_request(userid, lobby_id) - - "reject" -> - Lobby.deny_join_request(userid, lobby_id, data["reason"]) - - r -> - reply( - :system, - :error, - %{ - error: "invalid response type, no handler for '#{r}'", - location: "c.lobby_host.respond_to_join_request" - }, - state - ) - end - - state - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/lobby_host_out.ex b/lib/teiserver/protocols/tachyon_v1/lobby_host_out.ex deleted file mode 100644 index e95eec50f..000000000 --- a/lib/teiserver/protocols/tachyon_v1/lobby_host_out.ex +++ /dev/null @@ -1,33 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.LobbyHostOut do - alias Teiserver.Protocols.Tachyon.V1.Tachyon - - @spec do_reply(atom(), any) :: Map.t() - - ########### - # Query - def do_reply(:user_requests_to_join, {userid, script_password}) do - %{ - "cmd" => "s.lobby_host.user_requests_to_join", - "userid" => userid, - "script_password" => script_password - } - end - - ########### - # Join response - def do_reply(:join_response, {:approve, lobby}) do - %{ - "cmd" => "s.lobby_host.join_response", - "result" => "approve", - "lobby" => Tachyon.convert_object(lobby, :lobby) - } - end - - def do_reply(:join_response, {:reject, reason}) do - %{ - "cmd" => "s.lobby_host.join_response", - "result" => "reject", - "reason" => reason - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/lobby_in.ex b/lib/teiserver/protocols/tachyon_v1/lobby_in.ex deleted file mode 100644 index 2e2536305..000000000 --- a/lib/teiserver/protocols/tachyon_v1/lobby_in.ex +++ /dev/null @@ -1,275 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.LobbyIn do - alias Teiserver.Lobby - alias Teiserver.{Account, Battle, Client, Coordinator} - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.Protocols.Tachyon.V1.Tachyon - alias Teiserver.Protocols.TachyonLib - require Logger - alias Teiserver.Data.Types, as: T - - @spec do_handle(String.t(), Map.t(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - def do_handle("query", %{"query" => query} = cmd, state) do - fields = cmd["fields"] || ["lobby"] - - lobby_list = - Lobby.list_lobbies() - |> TachyonLib.query_in(:id, query["id_list"]) - |> TachyonLib.query(:locked, query["locked"]) - |> TachyonLib.query(:passworded, query["passworded"]) - |> Enum.map(fn lobby -> - fields - |> Map.new(fn f -> - case f do - "lobby" -> - {f, Tachyon.convert_object(lobby, :lobby)} - - "modoptions" -> - {f, Battle.get_modoptions(lobby.id)} - - "bots" -> - {f, Battle.get_bots(lobby.id)} - - "players" -> - {f, Battle.list_lobby_players(lobby.id)} - - "member_list" -> - clients = - lobby.id - |> Battle.get_lobby_member_list() - |> Account.list_clients() - |> Tachyon.convert_object(:client) - - {f, clients} - - _ -> - {"#{f}", "no field by that name"} - end - end) - end) - - reply(:lobby, :query, lobby_list, state) - - # `player_count` - Integer, a count of the number of players in the battle - # `spectator_count` - Integer, a count of the number of spectators in the battle - # `user_count` - Integer, a count of the number of players and spectators in the battle - # `player_list` - List (User.id), A list of player ids in the battle - # `spectator_list` - List (User.id), A list of spectator ids in the battle - # `user_list` - List (User.id), A list of player and spectator ids in the battle - end - - def do_handle("query", _, state) do - reply(:system, :error, %{error: "no query supplied", location: "c.lobby.query"}, state) - end - - def do_handle("get", %{"lobby_id" => lobby_id, "keys" => keys}, state) do - result = - keys - |> Map.new(fn k -> - case k do - "lobby" -> - {"lobby", Tachyon.convert_object(Battle.get_lobby(lobby_id), :lobby)} - - "bots" -> - {"bots", Battle.get_bots(lobby_id)} - - "players" -> - {"players", - Battle.list_lobby_players(lobby_id) - |> Enum.map(fn player -> - Tachyon.convert_object(player, :client) - end)} - - "members" -> - {"members", - Battle.get_lobby_member_list(lobby_id) - |> Enum.map(fn member_id -> - c = Account.get_client_by_id(member_id) - Tachyon.convert_object(c, :client) - end)} - - "modoptions" -> - {"modoptions", Battle.get_modoptions(lobby_id)} - end - end) - |> Map.put("lobby_id", lobby_id) - - reply(:lobby, :get, result, state) - end - - def do_handle("create", _, %{userid: nil} = state), do: reply(:system, :nouser, nil, state) - - def do_handle("create", %{"lobby" => lobby_dict}, state) do - lobby_keys = - ~w(cmd name nattype password port game_hash map_hash map_name game_name engine_name engine_version settings ip)a - - # Apply defaults - if Lobby.allow?(state.userid, :host, -1) do - lobby = - lobby_keys - |> Map.new(fn k -> {k, Map.get(lobby_dict, to_string(k))} end) - |> Map.put(:founder_id, state.userid) - |> Map.put(:founder_name, state.username) - |> Map.put(:ip, "127.0.0.1") - |> Lobby.create_lobby() - |> Lobby.add_lobby() - - Client.join_battle(state.userid, lobby.id, true) - - send(self(), {:action, {:host_lobby, lobby.id}}) - reply(:lobby, :create, {:success, lobby}, state) - else - reply(:lobby, :create, {:failure, "Permission denied"}, state) - end - end - - def do_handle("update", _, %{userid: nil} = state), do: reply(:system, :nouser, nil, state) - - def do_handle("update", %{"lobby" => lobby_dict}, state) do - update_keys = ~w(locked map_hash map_name name password)a - - if Lobby.allow?(state.userid, :updatebattleinfo, state.lobby_id) do - lobby = Lobby.get_lobby(state.lobby_id) - - updates = - update_keys - |> Map.new(fn k -> {k, Map.get(lobby_dict, to_string(k), Map.get(lobby, k))} end) - - new_lobby = Map.merge(lobby, updates) - - Lobby.update_lobby( - new_lobby, - nil, - :update_battle_info - ) - - reply(:lobby, :update, {:success, new_lobby}, state) - else - reply(:lobby, :update, {:failure, "Permission denied"}, state) - end - end - - def do_handle("join", _, %{userid: nil} = state), do: reply(:system, :nouser, nil, state) - - def do_handle("join", data, state) do - case Lobby.can_join?(state.userid, data["lobby_id"], data["password"]) do - {:waiting_on_host, script_password} -> - send(self(), {:action, {:set_script_password, script_password}}) - send(self(), {:action, {:leave_lobby, state.lobby_id}}) - reply(:lobby, :join, :waiting, state) - - {:failure, reason} -> - reply(:lobby, :join, {:failure, reason}, state) - end - end - - def do_handle("update_status", _, %{userid: nil} = state), - do: reply(:system, :nouser, nil, state) - - def do_handle("update_status", _, %{lobby_id: nil} = state), - do: reply(:system, :nolobby, nil, state) - - def do_handle("update_status", %{"client" => new_status}, state) do - updates = - new_status - |> Map.take(~w(in_game away ready player_number team_colour team_number player sync side)) - |> Map.new(fn {k, v} -> {String.to_atom(k), v} end) - - new_client = - Client.get_client_by_id(state.userid) - |> Map.merge(updates) - - if Lobby.allow?(state.userid, :my_battlestatus, state.lobby_id) do - case Coordinator.attempt_battlestatus_update(new_client, state.lobby_id) do - {true, allowed_client} -> - Client.update(allowed_client, :client_updated_battlestatus) - - {false, _} -> - :ok - - nil -> - nil - end - end - - state - end - - def do_handle("message", _, %{userid: nil} = state), do: reply(:system, :nouser, nil, state) - - def do_handle("message", _, %{lobby_id: nil} = state) do - reply(:lobby, :message, {:failure, "Not currently in a lobby"}, state) - end - - def do_handle("message", %{"message" => msg}, state) do - if Lobby.allow?(state.userid, :saylobby, state.lobby_id) do - Lobby.say(state.userid, msg, state.lobby_id) - end - - state - end - - def do_handle("leave", _, %{userid: nil} = state), do: reply(:system, :nouser, nil, state) - - def do_handle("leave", _, %{lobby_id: nil} = state) do - reply(:lobby, :leave, {:failure, "Not currently in a lobby"}, state) - end - - def do_handle("leave", _, state) do - send(self(), {:action, {:leave_lobby, state.lobby_id}}) - Lobby.remove_user_from_battle(state.userid, state.lobby_id) - new_state = %{state | lobby_id: nil, lobby_host: false} - reply(:lobby, :leave, {:success, nil}, new_state) - end - - def do_handle("add_bot", %{"name" => name, "status" => status, "ai_dll" => ai_dll}, state) do - if Lobby.allow?(state.userid, :add_bot, state.lobby_id) do - bot_status = - status - |> Map.take(~w(player_number team_colour team_number side)) - |> Map.new(fn {k, v} -> {String.to_atom(k), v} end) - |> Map.merge(%{ - player: true, - sync: %{engine: 1, game: 1, map: 1}, - ready: true - }) - - bot_data = - Lobby.new_bot( - Map.merge( - %{ - name: name, - owner_name: state.username, - owner_id: state.userid, - ai_dll: ai_dll - }, - bot_status - ) - ) - - Battle.add_bot_to_lobby(state.lobby_id, bot_data) - end - - state - end - - def do_handle("update_bot", %{"name" => name, "status" => status}, state) do - if Lobby.allow?(state.userid, {:update_bot, name}, state.lobby_id) do - bot_status = - status - |> Map.take(~w(player_number team_colour team_number side)) - |> Map.new(fn {k, v} -> {String.to_atom(k), v} end) - - Battle.update_bot(state.lobby_id, name, bot_status) - end - - state - end - - def do_handle("remove_bot", %{"name" => name}, state) do - if Lobby.allow?(state.userid, {:remove_bot, name}, state.lobby_id) do - Battle.remove_bot(state.lobby_id, name) - end - - state - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/lobby_out.ex b/lib/teiserver/protocols/tachyon_v1/lobby_out.ex deleted file mode 100644 index ec76c671a..000000000 --- a/lib/teiserver/protocols/tachyon_v1/lobby_out.ex +++ /dev/null @@ -1,482 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.LobbyOut do - alias Teiserver.{Account, Battle} - alias Teiserver.Lobby - alias Teiserver.Protocols.Tachyon.V1.Tachyon - - @spec do_reply(atom(), any) :: Map.t() | nil - - ########### - # Watching - def do_reply(:opened, %{lobby: lobby}) do - %{ - "cmd" => "s.lobby.opened", - "lobby" => Tachyon.convert_object(lobby, :lobby) - } - end - - def do_reply(:closed, %{lobby_id: lobby_id}) do - %{ - "cmd" => "s.lobby.closed", - "lobby_id" => lobby_id - } - end - - ########### - # Query - def do_reply(:query, lobby_list) do - %{ - "cmd" => "s.lobby.query", - "result" => "success", - "lobbies" => lobby_list - } - end - - ########### - # Query - def do_reply(:get, result) do - Map.put(result, "cmd", "s.lobby.get") - end - - ########### - # Create - def do_reply(:create, {:success, lobby}) do - %{ - "cmd" => "s.lobby.create", - "result" => "success", - "lobby" => Tachyon.convert_object(lobby, :lobby) - } - end - - def do_reply(:create, {:failure, reason}) do - %{ - "cmd" => "s.lobby.create", - "result" => "failure", - "reason" => reason - } - end - - ########### - # Update - def do_reply(:update, {:success, lobby}) do - %{ - "cmd" => "s.lobby.update", - "result" => "success", - "lobby" => Tachyon.convert_object(lobby, :lobby) - } - end - - def do_reply(:update, {:failure, reason}) do - %{ - "cmd" => "s.lobby.update", - "result" => "failure", - "reason" => reason - } - end - - ########### - # User Updates - def do_reply(:add_user, {_, %{lobby_id: lobby_id, client: client}}) do - user = Account.get_user_by_id(client.userid) - - %{ - "cmd" => "s.lobby.add_user", - "lobby_id" => lobby_id, - "joiner_id" => client.userid, - "client" => Tachyon.convert_object(client, :client), - "user" => Tachyon.convert_object(user, :user) - } - end - - def do_reply(:add_user, %{lobby_id: lobby_id, client: client}) do - user = Account.get_user_by_id(client.userid) - - %{ - "cmd" => "s.lobby.add_user", - "lobby_id" => lobby_id, - "joiner_id" => client.userid, - "client" => Tachyon.convert_object(client, :client), - "user" => Tachyon.convert_object(user, :user) - } - end - - def do_reply(:remove_user, {_lobby_id, %{lobby_id: lobby_id, client: client}}) do - %{ - "cmd" => "s.lobby.remove_user", - "lobby_id" => lobby_id, - "leaver_id" => client.userid - } - end - - def do_reply(:remove_user, %{lobby_id: lobby_id, client: client}) do - %{ - "cmd" => "s.lobby.remove_user", - "lobby_id" => lobby_id, - "leaver_id" => client.userid - } - end - - def do_reply(:kick_user, %{lobby_id: lobby_id, client: client}) do - %{ - "cmd" => "s.lobby.kick_user", - "lobby_id" => lobby_id, - "kicked_id" => client.userid - } - end - - def do_reply(:kick_user, {_lobby_id, %{lobby_id: lobby_id, client: client}}) do - %{ - "cmd" => "s.lobby.kick_user", - "lobby_id" => lobby_id, - "kicked_id" => client.userid - } - end - - def do_reply(:updated_client_battlestatus, {lobby_id, %{client: client, reason: reason}}) do - %{ - "cmd" => "s.lobby.updated_client_battlestatus", - "lobby_id" => lobby_id, - "client" => Tachyon.convert_object(client, :client), - "reason" => reason - } - end - - def do_reply(:updated_client_battlestatus, %{client: client, reason: reason, lobby_id: lobby_id}) do - %{ - "cmd" => "s.lobby.updated_client_battlestatus", - "lobby_id" => lobby_id, - "client" => Tachyon.convert_object(client, :client), - "reason" => reason - } - end - - ########### - # General Updates - def do_reply(:updated, {_, %{lobby_id: lobby_id}}) do - lobby = Lobby.get_lobby(lobby_id) - - %{ - "cmd" => "s.lobby.updated", - "lobby" => Tachyon.convert_object(lobby, :lobby) - } - end - - def do_reply(:updated, %{lobby_id: lobby_id}) do - lobby = Lobby.get_lobby(lobby_id) - - %{ - "cmd" => "s.lobby.updated", - "lobby" => Tachyon.convert_object(lobby, :lobby) - } - end - - def do_reply(:update_values, {_, %{lobby_id: lobby_id, changes: new_values}}) do - %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => new_values - } - end - - def do_reply(:update_values, %{lobby_id: lobby_id, changes: new_values}) do - %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => new_values - } - end - - def do_reply(:update_values, %{lobby_id: lobby_id, new_values: new_values}) do - %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => new_values - } - end - - def do_reply(:updated_queue, %{lobby_id: lobby_id, id_list: id_list}) do - %{ - "cmd" => "s.lobby.updated_queue", - "lobby_id" => lobby_id, - "queue" => id_list - } - end - - def do_reply(:updated_queue, {_, %{lobby_id: lobby_id, id_list: id_list}}) do - %{ - "cmd" => "s.lobby.updated_queue", - "lobby_id" => lobby_id, - "queue" => id_list - } - end - - ########### - # Start area updates - def do_reply(:add_start_area, {_, %{lobby_id: lobby_id, area_id: area_id, area: area}}) do - %{ - "cmd" => "s.lobby.add_start_area", - "lobby_id" => lobby_id, - "area_id" => area_id, - "structure" => area - } - end - - def do_reply(:add_start_area, %{lobby_id: lobby_id, area_id: area_id, area: area}) do - %{ - "cmd" => "s.lobby.add_start_area", - "lobby_id" => lobby_id, - "area_id" => area_id, - "structure" => area - } - end - - def do_reply(:remove_start_area, {_, %{lobby_id: lobby_id, area_id: area_id}}) do - %{ - "cmd" => "s.lobby.remove_start_area", - "lobby_id" => lobby_id, - "area_id" => area_id - } - end - - def do_reply(:remove_start_area, %{lobby_id: lobby_id, area_id: area_id}) do - %{ - "cmd" => "s.lobby.remove_start_area", - "lobby_id" => lobby_id, - "area_id" => area_id - } - end - - ########### - # Leave - def do_reply(:leave, {:success, nil}) do - %{ - "cmd" => "s.lobby.leave", - "result" => "success" - } - end - - def do_reply(:leave, {:failure, reason}) do - %{ - "cmd" => "s.lobby.leave", - "result" => "failure", - "reason" => reason - } - end - - ########### - # Join - def do_reply(:join, :waiting) do - %{ - "cmd" => "s.lobby.join", - "result" => "waiting_for_host" - } - end - - def do_reply(:join, {:failure, reason}) do - %{ - "cmd" => "s.lobby.join", - "result" => "failure", - "reason" => reason - } - end - - def do_reply(:force_join_lobby, {lobby_id, script_password}) do - case Battle.get_combined_lobby_state(lobby_id) do - nil -> - nil - - result -> - member_list = - result.member_list - |> Enum.uniq() - |> Enum.map(fn userid -> - client = Account.get_client_by_id(userid) - Tachyon.convert_object(client, :client) - end) - - send(self(), {:action, {:join_lobby, lobby_id}}) - - %{ - "cmd" => "s.lobby.force_join", - "lobby" => Tachyon.convert_object(result.lobby, :lobby), - "script_password" => script_password, - "modoptions" => result.modoptions, - "bots" => result.bots, - "member_list" => member_list - } - end - end - - ########### - # Join response - def do_reply(:join_lobby_request_response, {lobby_id, :deny, reason}) do - %{ - "cmd" => "s.lobby.join_response", - "result" => "reject", - "lobby_id" => lobby_id, - "reason" => reason - } - end - - # def do_reply(:join_lobby_request_response, {lobby_id, :accept, script_password}) do - # case Battle.get_combined_lobby_state(lobby_id) do - # nil -> - # %{ - # "cmd" => "s.lobby.join_response", - # "result" => "reject", - # "lobby_id" => lobby_id, - # "reason" => "closed" - # } - # result -> - # member_list = result.member_list - # |> Enum.uniq - # |> Enum.map(fn userid -> - # client = Account.get_client_by_id(userid) - # Tachyon.convert_object(client, :client) - # end) - - # send(self(), {:action, {:join_lobby, lobby_id}}) - # %{ - # "lobby" => Tachyon.convert_object(result.lobby, :lobby), - # "script_password" => script_password, - # "modoptions" => result.modoptions, - # "bots" => result.bots, - # "member_list" => member_list, - # "cmd" => "s.lobby.join_response", - # "result" => "approve", - # } - # end - # end - - def do_reply(:joined, {lobby_id, script_password}) do - case Battle.get_combined_lobby_state(lobby_id) do - nil -> - nil - - result -> - member_list = - result.member_list - |> Enum.uniq() - |> Enum.map(fn userid -> - client = Account.get_client_by_id(userid) - Tachyon.convert_object(client, :client) - end) - - send(self(), {:action, {:join_lobby, lobby_id}}) - - %{ - "cmd" => "s.lobby.joined", - "lobby" => Tachyon.convert_object(result.lobby, :lobby), - "script_password" => script_password, - "modoptions" => result.modoptions, - "bots" => result.bots, - "member_list" => member_list - } - end - end - - ########### - # Modoptions - def do_reply(:set_modoption, {_lobby_id, msg}) do - %{ - "cmd" => "s.lobby.set_modoptions", - "lobby_id" => msg.lobby_id, - "new_options" => %{ - msg.key => msg.value - } - } - end - - def do_reply(:set_modoption, msg) do - %{ - "cmd" => "s.lobby.set_modoptions", - "lobby_id" => msg.lobby_id, - "new_options" => %{ - msg.key => msg.value - } - } - end - - def do_reply(:set_modoptions, {_lobby_id, msg}) do - %{ - "cmd" => "s.lobby.set_modoptions", - "lobby_id" => msg.lobby_id, - "new_options" => msg.options - } - end - - def do_reply(:set_modoptions, msg) do - %{ - "cmd" => "s.lobby.set_modoptions", - "lobby_id" => msg.lobby_id, - "new_options" => msg.options - } - end - - def do_reply(:remove_modoptions, msg) do - %{ - "cmd" => "s.lobby.remove_modoptions", - "lobby_id" => msg.lobby_id, - "keys" => msg.keys - } - end - - ########### - # Bots - def do_reply(:add_bot, {_, msg}) do - %{ - "cmd" => "s.lobby.add_bot", - # "lobby_id" => msg.lobby_id, - "bot" => msg.bot - } - end - - def do_reply(:add_bot, msg) do - %{ - "cmd" => "s.lobby.add_bot", - # "lobby_id" => msg.lobby_id, - "bot" => msg.bot - } - end - - def do_reply(:update_bot, {_, msg}) do - %{ - "cmd" => "s.lobby.update_bot", - # "lobby_id" => msg.lobby_id, - "bot" => msg.bot - } - end - - def do_reply(:update_bot, msg) do - %{ - "cmd" => "s.lobby.update_bot", - # "lobby_id" => msg.lobby_id, - "bot" => msg.bot - } - end - - def do_reply(:remove_bot, {_, msg}) do - %{ - "cmd" => "s.lobby.remove_bot", - # "lobby_id" => msg.lobby_id, - "bot_name" => msg.bot - } - end - - def do_reply(:remove_bot, msg) do - %{ - "cmd" => "s.lobby.remove_bot", - # "lobby_id" => msg.lobby_id, - "bot_name" => msg.bot - } - end - - ########### - # Messages - def do_reply(:received_lobby_direct_announce, {sender_id, msg}) do - %{ - "cmd" => "s.lobby.received_lobby_direct_announce", - "sender_id" => sender_id, - "message" => msg - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/matchmaking_in.ex b/lib/teiserver/protocols/tachyon_v1/matchmaking_in.ex deleted file mode 100644 index 027dfeea9..000000000 --- a/lib/teiserver/protocols/tachyon_v1/matchmaking_in.ex +++ /dev/null @@ -1,83 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.MatchmakingIn do - # alias Teiserver.Client - alias Teiserver.Data.Matchmaking - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - - @spec do_handle(String.t(), Map.t(), Map.t()) :: Map.t() - def do_handle("query", %{"query" => _query}, state) do - queues = Matchmaking.list_queues() - reply(:matchmaking, :query, queues, state) - end - - def do_handle("list_my_queues", _, state) do - queues = Matchmaking.list_queues(state.queues) - reply(:matchmaking, :your_queue_list, queues, state) - end - - def do_handle("get_queue_info", %{"queue_id" => queue_id}, state) when is_integer(queue_id) do - {queue, info} = Matchmaking.get_queue_and_info(queue_id) - reply(:matchmaking, :queue_info, {queue, info}, state) - end - - def do_handle("join_queue", %{"queue_id" => queue_id}, state) when is_integer(queue_id) do - resp = Matchmaking.add_user_to_queue(queue_id, state.userid) - - joined = - case resp do - :ok -> true - :duplicate -> true - :failed -> false - :missing -> false - :oversized_group -> false - :moderated -> false - :not_party_leader -> false - :no_queue -> false - end - - case joined do - true -> - state - - false -> - reason = - case resp do - :missing -> "No queue found" - :no_queue -> "No queue found" - :moderated -> "Moderation action" - :not_party_leader -> "Not party leader" - :oversized_group -> "Group is larger than the queue team size" - _ -> "Failure" - end - - reply(:matchmaking, :join_queue_failure, {queue_id, reason}, state) - end - end - - def do_handle("leave_queue", %{"queue_id" => queue_id}, state) when is_integer(queue_id) do - Matchmaking.remove_group_from_queue(queue_id, state.userid) - state - end - - def do_handle("leave_all_queues", _cmd, state) do - state.queues - |> Enum.each(fn queue_id -> - Matchmaking.remove_group_from_queue(queue_id, state.userid) - end) - - state - end - - def do_handle("accept", %{"match_id" => match_id}, state) do - Matchmaking.player_accept(match_id, state.userid) - state - end - - def do_handle("decline", %{"match_id" => match_id}, state) do - Matchmaking.player_decline(match_id, state.userid) - state - end - - # def do_handle(cmd, data, msg_id, state) do - # SpringIn._no_match(state, "c.matchmaking." <> cmd, msg_id, data) - # end -end diff --git a/lib/teiserver/protocols/tachyon_v1/matchmaking_out.ex b/lib/teiserver/protocols/tachyon_v1/matchmaking_out.ex deleted file mode 100644 index 31b0ee21a..000000000 --- a/lib/teiserver/protocols/tachyon_v1/matchmaking_out.ex +++ /dev/null @@ -1,174 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.MatchmakingOut do - alias Teiserver.Protocols.Tachyon.V1.Tachyon - - @spec do_reply(atom(), any) :: Map.t() - - ########### - # Query - def do_reply(:query, queue_list) do - %{ - "cmd" => "s.matchmaking.query", - "result" => "success", - "queues" => - queue_list - |> Enum.map(fn b -> Tachyon.convert_object(b, :queue) end) - } - end - - def do_reply(:your_queue_list, queue_list) do - %{ - "cmd" => "s.matchmaking.your_queue_list", - "result" => "success", - "queues" => - queue_list - |> Enum.map(fn b -> Tachyon.convert_object(b, :queue) end) - } - end - - def do_reply(:queue_info, {queue, info}) do - %{ - "cmd" => "s.matchmaking.queue_info", - "queue" => %{ - "queue_id" => queue.id, - "name" => queue.name, - "mean_wait_time" => info.mean_wait_time, - "group_count" => info.group_count - } - } - end - - # ########### - # # Create - # def do_reply(:create, {:success, queue}) do - # %{ - # "cmd" => "s.matchmaking.create", - # "result" => "success", - # "queue" => Tachyon.convert_object(queue, :queue) - # } - # end - - # ########### - # # Leave - # def do_reply(:leave, {:success, nil}) do - # %{ - # "cmd" => "s.matchmaking.leave", - # "result" => "success" - # } - # end - - # def do_reply(:leave, {:failure, reason}) do - # %{ - # "cmd" => "s.matchmaking.leave", - # "result" => "failure", - # "reason" => reason - # } - # end - - ########### - # Join - def do_reply(:join_queue_success, queue_id) do - %{ - "cmd" => "s.matchmaking.join_queue", - "result" => "success", - "queue_id" => queue_id - } - end - - def do_reply(:join_queue_failure, {queue_id, reason}) do - %{ - "cmd" => "s.matchmaking.join_queue", - "result" => "failure", - "reason" => reason, - "queue_id" => queue_id - } - end - - def do_reply(:match_ready, {queue_id, match_id}) do - %{ - "cmd" => "s.matchmaking.match_ready", - "queue_id" => queue_id, - "match_id" => match_id - } - end - - def do_reply(:match_declined, {queue_id, match_id}) do - %{ - "cmd" => "s.matchmaking.match_declined", - "queue_id" => queue_id, - "match_id" => match_id - } - end - - def do_reply(:match_cancelled, {queue_id, match_id}) do - %{ - "cmd" => "s.matchmaking.match_cancelled", - "queue_id" => queue_id, - "match_id" => match_id - } - end - - # def do_reply(:join, {:failure, reason}) do - # %{ - # "cmd" => "s.matchmaking.join", - # "result" => "failure", - # "reason" => reason - # } - # end - - # ########### - # # Join request - # def do_reply(:request_to_join, userid) do - # %{ - # "cmd" => "s.matchmaking.request_to_join", - # "userid" => userid - # } - # end - - # ########### - # # Join response - # def do_reply(:join_response, {:approve, queue}) do - # %{ - # "cmd" => "s.matchmaking.join_response", - # "result" => "approve", - # "queue" => Tachyon.convert_object(queue, :queue) - # } - # end - - # def do_reply(:join_response, {:reject, reason}) do - # %{ - # "cmd" => "s.matchmaking.join_response", - # "result" => "reject", - # "reason" => reason - # } - # end - - # ########### - # # Messages - # def do_reply(:request_status, nil) do - # %{ - # "cmd" => "s.matchmaking.request_status" - # } - # end - - # ########### - # # Messages - # def do_reply(:message, {sender_id, msg, _queue_id}) do - # %{ - # "cmd" => "s.matchmaking.message", - # "sender_id" => sender_id, - # "message" => msg - # } - # end - - # def do_reply(:announce, {sender_id, msg, _queue_id}) do - # %{ - # "cmd" => "s.matchmaking.announce", - # "sender_id" => sender_id, - # "message" => msg - # } - # end - - # def do_reply(_, _) do - # # TODO: Implement Tachyon matchmaking - # end -end diff --git a/lib/teiserver/protocols/tachyon_v1/party_in.ex b/lib/teiserver/protocols/tachyon_v1/party_in.ex deleted file mode 100644 index 97f9e72b0..000000000 --- a/lib/teiserver/protocols/tachyon_v1/party_in.ex +++ /dev/null @@ -1,121 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.PartyIn do - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.{Account} - alias Teiserver.Account.PartyLib - - @spec do_handle(String.t(), Map.t(), Map.t()) :: Map.t() - def do_handle("create", _, state) do - party = Account.create_party(state.userid) - send(self(), {:action, {:lead_party, party.id}}) - # reply(:party, :added_to, party.id, state) - state - end - - def do_handle("info", %{"party_id" => party_id}, state) do - case Account.get_party(party_id) do - nil -> - reply(:party, :info_public, nil, state) - - party -> - full_info = Enum.member?(party.pending_invites ++ party.members, state.userid) - - if full_info do - reply(:party, :info_full, party, state) - else - reply(:party, :info_public, party, state) - end - end - end - - def do_handle("invite", %{"userid" => userid}, state) do - if state.party_id != nil do - Account.create_party_invite(state.party_id, userid) - end - - state - end - - def do_handle("cancel", %{"userid" => userid}, state) do - if state.party_id != nil and state.party_role == :leader do - Account.cancel_party_invite(state.party_id, userid) - end - - state - end - - # Accepting when not a member of a party - def do_handle("accept", %{"party_id" => party_id}, %{party_id: nil} = state) do - case Account.accept_party_invite(party_id, state.userid) do - {true, party} -> - send(self(), {:action, {:join_party, party.id}}) - state - - {false, reason} -> - reply(:party, :accept, {false, reason}, state) - - nil -> - reply(:party, :accept, {false, "No party found"}, state) - end - - state - end - - def do_handle("accept", %{"party_id" => party_id}, %{party_id: existing_party_id} = state) do - case Account.accept_party_invite(party_id, state.userid) do - {true, party} -> - send(self(), {:action, {:leave_party, existing_party_id}}) - PartyLib.cast_party(existing_party_id, {:member_leave, state.userid}) - - send(self(), {:action, {:join_party, party.id}}) - state - - {false, reason} -> - reply(:party, :accept, {false, reason}, state) - - nil -> - reply(:party, :accept, {false, "No party found"}, state) - end - - state - end - - def do_handle("decline", %{"party_id" => party_id}, state) do - PartyLib.cast_party(party_id, {:cancel_invite, state.userid}) - state - end - - # Past this point if they're not in a party don't even bother doing anything - def do_handle(_, _, %{party_id: nil} = state) do - state - end - - def do_handle("kick", %{"user_id" => user_id}, state) when is_integer(user_id) do - party = Account.get_party(state.party_id) - - if state.userid == party.leader do - Account.kick_user_from_party(state.party_id, user_id) - end - end - - def do_handle("new_leader", %{"user_id" => user_id}, state) when is_integer(user_id) do - party = Account.get_party(state.party_id) - - if state.userid == party.leader do - PartyLib.cast_party(state.party_id, {:new_leader, user_id}) - end - - state - end - - def do_handle("leave", _, state) do - PartyLib.cast_party(state.party_id, {:member_leave, state.userid}) - Account.move_client_to_party(state.userid, nil) - send(self(), {:action, {:leave_party, state.party_id}}) - state - end - - def do_handle("message", %{"message" => message}, state) do - PartyLib.say(state.userid, state.party_id, message) - state - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/party_out.ex b/lib/teiserver/protocols/tachyon_v1/party_out.ex deleted file mode 100644 index e5022c2de..000000000 --- a/lib/teiserver/protocols/tachyon_v1/party_out.ex +++ /dev/null @@ -1,69 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.PartyOut do - @moduledoc false - alias Teiserver.Account - alias Teiserver.Protocols.Tachyon.V1.Tachyon - - @spec do_reply(atom(), any) :: Map.t() - def do_reply(:info_public, party) do - %{ - cmd: "s.party.info", - party: Tachyon.convert_object(party, :party_public) - } - end - - def do_reply(:info_full, party) do - %{ - cmd: "s.party.info", - party: Tachyon.convert_object(party, :party_full) - } - end - - def do_reply(:updated, {party_id, new_values}) do - %{ - cmd: "s.party.updated", - party_id: party_id, - new_values: new_values - } - end - - def do_reply(:invite, party_id) do - party = Account.get_party(party_id) - - %{ - cmd: "s.party.invite", - party: Tachyon.convert_object(party, :party_full) - } - end - - def do_reply(:added_to, party_id) do - party = Account.get_party(party_id) - - %{ - cmd: "s.party.added_to", - party: Tachyon.convert_object(party, :party_full) - } - end - - def do_reply(:left_party, party_id) do - %{ - cmd: "s.party.left_party", - party_id: party_id - } - end - - def do_reply(:accept, {false, reason}) do - %{ - cmd: "s.party.accept", - result: "failure", - reason: reason - } - end - - def do_reply(:message, {sender_id, message}) when is_integer(sender_id) do - %{ - cmd: "s.party.message", - sender_id: sender_id, - message: message - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/system_in.ex b/lib/teiserver/protocols/tachyon_v1/system_in.ex deleted file mode 100644 index 584526ad1..000000000 --- a/lib/teiserver/protocols/tachyon_v1/system_in.ex +++ /dev/null @@ -1,87 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.SystemIn do - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.{Account, Battle} - import Teiserver.Helper.NumberHelper, only: [int_parse: 1] - - @spec do_handle(String.t(), Map.t(), Map.t()) :: Map.t() - def do_handle("ping", cmd, state) do - reply(:system, :pong, cmd, state) - end - - def do_handle("watch", %{"channel" => channel}, state) do - case channel do - "friends" -> - Account.list_friend_ids_of_user(state.userid) - |> Enum.each(fn f -> - send(self(), {:action, {:watch_channel, "teiserver_client_watch:#{f}"}}) - end) - - reply(:system, :watch, {:ok, channel}, state) - - "friend:" <> f -> - f_id = int_parse(f) - friends = Account.list_friend_ids_of_user(state.userid) - - if Enum.member?(friends, f_id) do - send(self(), {:action, {:watch_channel, "teiserver_client_watch:#{f}"}}) - reply(:system, :watch, {:ok, channel}, state) - else - reply(:system, :watch, {:error, channel, "Not a friend"}, state) - end - - "server_stats" -> - send(self(), {:action, {:watch_channel, "teiserver_public_stats"}}) - reply(:system, :watch, {:ok, channel}, state) - - "all_lobbies" -> - send(self(), {:action, {:watch_channel, "teiserver_global_lobby_updates"}}) - reply(:system, :watch, {:ok, channel}, state) - - "lobby:" <> lobby_id -> - lobby_id = int_parse(lobby_id) - - case Battle.lobby_exists?(lobby_id) do - true -> - send(self(), {:action, {:watch_channel, "teiserver_lobby_updates:#{lobby_id}"}}) - reply(:system, :watch, {:ok, channel}, state) - - false -> - reply(:lobby, :watch, {:failure, "No lobby", lobby_id}, state) - end - - _ -> - reply(:system, :watch, {:failure, channel, "No channel"}, state) - end - end - - def do_handle("unwatch", %{"channel" => channel}, state) do - case channel do - "friends" -> - Account.list_friend_ids_of_user(state.userid) - |> Enum.each(fn f -> - send(self(), {:action, {:watch_channel, "teiserver_client_watch:#{f}"}}) - end) - - reply(:system, :unwatch, {:ok, channel}, state) - - "friend:" <> f -> - send(self(), {:action, {:unwatch_channel, "teiserver_client_watch:#{f}"}}) - reply(:system, :unwatch, {:ok, channel}, state) - - "server_stats" -> - send(self(), {:action, {:unwatch_channel, "teiserver_public_stats"}}) - reply(:system, :unwatch, {:ok, channel}, state) - - "all_lobbies" -> - send(self(), {:action, {:unwatch_channel, "teiserver_global_lobby_updates"}}) - reply(:system, :unwatch, {:ok, channel}, state) - - "lobby:" <> lobby_id -> - send(self(), {:action, {:unwatch_channel, "teiserver_lobby_updates:#{lobby_id}"}}) - reply(:system, :unwatch, {:ok, channel}, state) - - _ -> - reply(:system, :unwatch, {:failure, channel, "No channel"}, state) - end - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/system_out.ex b/lib/teiserver/protocols/tachyon_v1/system_out.ex deleted file mode 100644 index cec18eb78..000000000 --- a/lib/teiserver/protocols/tachyon_v1/system_out.ex +++ /dev/null @@ -1,96 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.SystemOut do - @spec do_reply(atom(), any) :: Map.t() - def do_reply(:pong, _data) do - %{ - cmd: "s.system.pong", - time: System.system_time(:second) - } - end - - def do_reply(:server_stats, data) do - %{ - cmd: "s.system.server_stats", - data: data - } - end - - def do_reply(:watch, {:ok, channel}) do - %{ - cmd: "s.system.watch", - result: "success", - channel: channel - } - end - - def do_reply(:watch, {:failure, channel, reason}) do - %{ - cmd: "s.system.watch", - result: "failure", - reason: reason, - channel: channel - } - end - - def do_reply(:unwatch, {:ok, channel}) do - %{ - cmd: "s.system.unwatch", - result: "success", - channel: channel - } - end - - def do_reply(:unwatch, {:failure, channel, reason}) do - %{ - cmd: "s.system.unwatch", - result: "failure", - reason: reason, - channel: channel - } - end - - def do_reply(:ring, ringer_id) do - %{ - cmd: "s.system.ring", - ringer_id: ringer_id - } - end - - def do_reply(:nouser, nil) do - %{ - result: "error", - error: "not logged in" - } - end - - def do_reply(:nolobby, nil) do - %{ - result: "error", - error: "not in a lobby" - } - end - - def do_reply(:noauth, nil) do - %{ - result: "error", - error: "no authorisation" - } - end - - def do_reply(:server_event, {:started, _}), do: nil - - def do_reply(:server_event, {event, node}) do - %{ - cmd: "s.system.server_event", - event: event, - node: node - } - end - - def do_reply(:error, data) do - %{ - result: "error", - error: data.error, - location: data.location - } - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/tachyon.ex b/lib/teiserver/protocols/tachyon_v1/tachyon.ex deleted file mode 100644 index 9436ae6fb..000000000 --- a/lib/teiserver/protocols/tachyon_v1/tachyon.ex +++ /dev/null @@ -1,207 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.Tachyon do - @moduledoc """ - Used for library-like functions that are specific to a version. - """ - - alias Teiserver.{Client, CacheUser} - alias Phoenix.PubSub - alias Teiserver.Data.Types, as: T - require Logger - - @spec protocol_in :: Teiserver.Protocols.Tachyon.V1.TachyonIn - def protocol_in(), do: Teiserver.Protocols.Tachyon.V1.TachyonIn - - @spec protocol_out :: Teiserver.Protocols.Tachyon.V1.TachyonOut - def protocol_out(), do: Teiserver.Protocols.Tachyon.V1.TachyonOut - - @doc """ - Used to convert objects into something that will be sent back over the wire. We use this - as there might be internal fields we don't want sent out (e.g. email). - """ - @spec convert_object( - Map.t() | nil, - :user | :user_extended | :user_extended_icons | :client | :battle | :queue - ) :: Map.t() | nil - def convert_object(nil, _), do: nil - - def convert_object(objects, type) when is_list(objects) do - objects - |> Enum.map(fn object -> convert_object(object, type) end) - end - - def convert_object(user, :user) do - Map.merge( - Map.take(user, ~w(id name bot clan_id country)a), - %{"icons" => Teiserver.Account.UserLib.generate_user_icons(user)} - ) - end - - def convert_object(user, :user_extended), do: Map.take(user, ~w(id name bot clan_id permissions - friends friend_requests ignores country)a) - - def convert_object(user, :user_extended_icons) do - Map.merge( - convert_object(user, :user_extended), - %{"icons" => Teiserver.Account.UserLib.generate_user_icons(user)} - ) - end - - def convert_object(client, :client) do - sync_list = - case client.sync do - true -> ["game", "map"] - 1 -> ["game", "map"] - false -> [] - 0 -> [] - s -> s - end - - Map.take(client, ~w(userid in_game away ready player_number - team_number team_colour player bonus muted clan_tag - faction lobby_id)a) - |> Map.put(:sync, sync_list) - |> Map.put(:party_id, nil) - end - - def convert_object(client, :client_friend) do - sync_list = - case client.sync do - true -> ["game", "map"] - 1 -> ["game", "map"] - false -> [] - 0 -> [] - s -> s - end - - Map.take(client, ~w(userid in_game away ready player_number - team_number team_colour player bonus muted party_id clan_tag - faction lobby_id)a) - |> Map.put(:sync, sync_list) - end - - def convert_object(queue, :queue), - do: Map.take(queue, ~w(id name team_size conditions settings map_list)a) - - def convert_object(party, :party_full), - do: Map.take(party, ~w(id leader members pending_invites)a) - - def convert_object(party, :party_public), do: Map.take(party, ~w(id leader members)a) - - def convert_object(type, :user_config_type) do - opts = type[:opts] |> Map.new() - - Map.take(type, ~w(default description key section type value_label)a) - |> Map.put(:opts, opts) - end - - # Slightly more complex conversions - def convert_object(lobby, :lobby) do - Map.take(lobby, ~w(id name founder_id type max_players game_name - locked engine_name engine_version players spectators bots ip port - settings map_name passworded public - map_hash tags disabled_units in_progress started_at start_areas)a) - end - - @spec do_action(atom, any(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - def do_action(:login_accepted, user, state) do - # Login the client - _client = Client.login(user, :tachyon, state.ip) - - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_client_messages:#{user.id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_user_updates:#{user.id}") - - PubSub.subscribe(Teiserver.PubSub, "teiserver_client_messages:#{user.id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_user_updates:#{user.id}") - - Logger.metadata(request_id: "TachyonTcpServer##{user.id}") - - exempt_from_cmd_throttle = - CacheUser.is_moderator?(user) == true or CacheUser.is_bot?(user) == true - - %{ - state - | username: user.name, - userid: user.id, - exempt_from_cmd_throttle: exempt_from_cmd_throttle - } - end - - def do_action(:host_lobby, lobby_id, state) do - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_host_message:#{lobby_id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_host_message:#{lobby_id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - %{state | lobby_id: lobby_id, lobby_host: true} - end - - def do_action(:leave_lobby, lobby_id, state) do - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - %{state | lobby_id: nil, lobby_host: false} - end - - def do_action(:join_lobby, lobby_id, state) do - Teiserver.Lobby.add_user_to_battle(state.userid, lobby_id, state.script_password) - - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_updates:#{lobby_id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_lobby_chat:#{lobby_id}") - - %{state | lobby_id: lobby_id} - end - - def do_action(:lead_party, party_id, state) do - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_party:#{party_id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_party:#{party_id}") - - %{state | party_id: party_id, party_role: :leader} - end - - def do_action(:join_party, party_id, state) do - # We need this check so we don't overwrite our leader status - if state.party_id != party_id do - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_party:#{party_id}") - PubSub.subscribe(Teiserver.PubSub, "teiserver_party:#{party_id}") - - %{state | party_id: party_id, party_role: :member} - else - state - end - end - - def do_action(:leave_party, party_id, state) do - PubSub.unsubscribe(Teiserver.PubSub, "teiserver_party:#{party_id}") - - if state.party_id == party_id do - %{state | party_id: nil, party_role: nil} - else - state - end - end - - def do_action(:joined_queue, queue_id, state) do - %{state | queues: Enum.uniq([queue_id | state.queues])} - end - - def do_action(:left_queue, queue_id, state) do - %{state | queues: List.delete(state.queues, queue_id)} - end - - def do_action(:watch_channel, name, state) do - PubSub.unsubscribe(Teiserver.PubSub, name) - PubSub.subscribe(Teiserver.PubSub, name) - - state - end - - def do_action(:unwatch_channel, name, state) do - PubSub.unsubscribe(Teiserver.PubSub, name) - - state - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/tachyon_in.ex b/lib/teiserver/protocols/tachyon_v1/tachyon_in.ex deleted file mode 100644 index e2152a4dc..000000000 --- a/lib/teiserver/protocols/tachyon_v1/tachyon_in.ex +++ /dev/null @@ -1,149 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.TachyonIn do - require Logger - alias Teiserver.Protocols.TachyonLib - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - import Teiserver.Helper.NumberHelper, only: [int_parse: 1] - - alias Teiserver.Protocols.Tachyon.V1.{ - AuthIn, - ClientIn, - CommunicationIn, - ConfigIn, - LobbyHostIn, - LobbyIn, - MatchmakingIn, - PartyIn, - SystemIn, - TelemetryIn, - UserIn - } - - @spec data_in(String.t(), map()) :: map() - def data_in(data, state) do - new_state = - if String.ends_with?(data, "\n") do - data = state.message_part <> data - - data - |> String.split("\n") - |> Enum.reduce(state, fn data, acc -> - handle(data, acc) - end) - |> Map.put(:message_part, "") - else - %{state | message_part: state.message_part <> data} - end - - new_state - end - - @spec handle(String.t(), map) :: map - def handle("", state), do: state - def handle("\n", state), do: state - def handle("\r\n", state), do: state - - def handle(raw_data, state) do - clean_data = - raw_data - |> String.trim() - - case TachyonLib.decode(clean_data) do - {:ok, data} -> - dispatch(data["cmd"], data, state) - - {:error, error_type} -> - reply(:system, :error, %{location: "decode", error: error_type}, state) - end - - %{state | last_msg: System.system_time(:second)} - end - - # If the data has a message id we add it to the state, saves us passing around - # an extra value all the time and might help with debugging at some point - @spec add_msg_id(map(), map()) :: map() - defp add_msg_id(state, data) do - new_msg_id = - if Map.has_key?(data, "msg_id") do - int_parse(data["msg_id"]) - end - - %{state | msg_id: new_msg_id} - end - - @spec dispatch(String.t(), map(), map()) :: map() - defp dispatch(nil, data, state) do - reply( - :system, - :error, - %{ - location: "dispatch", - error: "cmd with nil value passed in with data '#{Kernel.inspect(data)}'" - }, - state - ) - end - - defp dispatch(cmd, data, state) do - state = - state - |> add_msg_id(data) - - new_state = - case String.split(cmd, ".") do - ["c", namespace, subcommand] -> - case namespace do - "auth" -> - AuthIn.do_handle(subcommand, data, state) - - "client" -> - ClientIn.do_handle(subcommand, data, state) - - "communication" -> - CommunicationIn.do_handle(subcommand, data, state) - - "config" -> - ConfigIn.do_handle(subcommand, data, state) - - "lobby_host" -> - LobbyHostIn.do_handle(subcommand, data, state) - - "lobby" -> - LobbyIn.do_handle(subcommand, data, state) - - "matchmaking" -> - MatchmakingIn.do_handle(subcommand, data, state) - - "party" -> - PartyIn.do_handle(subcommand, data, state) - - "system" -> - SystemIn.do_handle(subcommand, data, state) - - "telemetry" -> - TelemetryIn.do_handle(subcommand, data, state) - - "user" -> - UserIn.do_handle(subcommand, data, state) - - _ -> - reply( - :system, - :error, - %{location: "dispatch", error: "No dispatch for namespace '#{namespace}'"}, - state - ) - end - - _ -> - reply( - :system, - :error, - %{location: "parse", error: "Unable to parse cmd '#{cmd}'"}, - state - ) - end - - # And remove the msg_id, don't want that bleeding over - %{new_state | msg_id: nil} - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex b/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex deleted file mode 100644 index 5f709c6ec..000000000 --- a/lib/teiserver/protocols/tachyon_v1/tachyon_out.ex +++ /dev/null @@ -1,88 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.TachyonOut do - require Logger - alias Teiserver.Protocols.TachyonLib - - alias Teiserver.Protocols.Tachyon.V1.{ - AuthOut, - ClientOut, - CommunicationOut, - ConfigOut, - LobbyChatOut, - LobbyHostOut, - LobbyOut, - MatchmakingOut, - PartyOut, - SystemOut, - UserOut - } - - @spec reply(atom(), atom(), Map.t(), Map.t()) :: Map.t() - - def reply(namespace, reply_cmd, data, state) do - msg = - case namespace do - :auth -> - AuthOut.do_reply(reply_cmd, data) - - :client -> - ClientOut.do_reply(reply_cmd, data) - - :communication -> - CommunicationOut.do_reply(reply_cmd, data) - - :config -> - ConfigOut.do_reply(reply_cmd, data) - - :lobby_chat -> - LobbyChatOut.do_reply(reply_cmd, data) - - :lobby_host -> - LobbyHostOut.do_reply(reply_cmd, data) - - :lobby -> - LobbyOut.do_reply(reply_cmd, data) - - :battle -> - Logger.warning("Tachyon :battle namespace message #{reply_cmd}") - LobbyOut.do_reply(reply_cmd, data) - - :matchmaking -> - MatchmakingOut.do_reply(reply_cmd, data) - - :party -> - PartyOut.do_reply(reply_cmd, data) - - :system -> - SystemOut.do_reply(reply_cmd, data) - - :user -> - UserOut.do_reply(reply_cmd, data) - end - |> add_msg_id(state) - - _send(msg, state) - state - end - - @spec add_msg_id(Map.t(), Map.t()) :: Map.t() - defp add_msg_id(resp, state) do - if state.msg_id do - Map.put(resp, :msg_id, state.msg_id) - else - resp - end - end - - # This sends a message to the self to send out a message - @spec _send(nil | Map.t(), Map.t()) :: any() - defp _send(nil, _), do: :ok - - defp _send(msg, state) do - _send(msg, state.socket, state.transport) - end - - defp _send(msg, socket, transport) do - encoded_msg = TachyonLib.encode(msg) - transport.send(socket, encoded_msg <> "\n") - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/telemetry_in.ex b/lib/teiserver/protocols/tachyon_v1/telemetry_in.ex deleted file mode 100644 index 3eae1b88c..000000000 --- a/lib/teiserver/protocols/tachyon_v1/telemetry_in.ex +++ /dev/null @@ -1,18 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.TelemetryIn do - alias Teiserver.Telemetry - - @spec do_handle(String.t(), Map.t(), Map.t()) :: Map.t() - def do_handle( - "update_property", - %{"property" => property, "value" => value}, - state - ) do - Telemetry.log_user_property(state.userid, property, value) - state - end - - def do_handle("log_event", %{"event" => event, "value" => value}, state) do - Telemetry.log_complex_client_event(state.userid, event, value) - state - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/user_in.ex b/lib/teiserver/protocols/tachyon_v1/user_in.ex deleted file mode 100644 index 1228f8df7..000000000 --- a/lib/teiserver/protocols/tachyon_v1/user_in.ex +++ /dev/null @@ -1,108 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.UserIn do - alias Teiserver.{Account, CacheUser, Client} - alias Teiserver.Protocols.Tachyon.V1.Tachyon - import Teiserver.Protocols.Tachyon.V1.TachyonOut, only: [reply: 4] - alias Teiserver.Data.Types, as: T - - @spec do_handle(String.t(), Map.t(), T.tachyon_tcp_state()) :: T.tachyon_tcp_state() - def do_handle("query", %{"query" => _query}, state) do - state - end - - def do_handle("list_users_from_ids", %{"id_list" => id_list} = args, state) do - users = - id_list - |> CacheUser.list_users() - |> Enum.filter(fn u -> u != nil end) - |> Enum.map(fn u -> - stats = Account.get_user_stat_data(u.id) - - updated_u = - Map.merge(u, %{ - country: stats["country"], - icons: %{ - "play_time_rank" => stats["rank"] - } - }) - - Tachyon.convert_object(updated_u, :user) - end) - - if Map.get(args, "include_clients", true) do - clients = - id_list - |> Client.list_clients() - |> Enum.filter(fn c -> c != nil end) - |> Enum.map(fn c -> Tachyon.convert_object(c, :client) end) - - reply(:user, :user_list, {users, clients}, state) - else - reply(:user, :user_list, users, state) - end - end - - def do_handle("list_friend_ids", _, state) do - friend_list = Account.list_friend_ids_of_user(state.userid) - request_list = Account.list_incoming_friend_requests_of_userid(state.userid) - - reply(:user, :list_friend_ids, {friend_list, request_list}, state) - end - - def do_handle("list_friend_users_and_clients", _, state) do - friend_list = Account.list_friend_ids_of_user(state.userid) - - users = - friend_list - |> Account.list_users_from_cache() - |> Enum.reject(&(&1 == nil)) - |> Tachyon.convert_object(:user) - - clients = - friend_list - |> Account.list_clients() - |> Enum.reject(&(&1 == nil)) - |> Tachyon.convert_object(:client_friend) - - reply(:user, :list_friend_users_and_clients, {users, clients}, state) - end - - def do_handle("add_friend", %{"user_id" => user_id}, state) when is_integer(user_id) do - Account.create_friend_request(state.userid, user_id) - state - end - - def do_handle("rescind_friend_request", %{"user_id" => user_id}, state) - when is_integer(user_id) do - Account.rescind_friend_request(state.userid, user_id) - state - end - - def do_handle("accept_friend_request", %{"user_id" => user_id}, state) - when is_integer(user_id) do - Account.accept_friend_request(user_id, state.userid) - state - end - - def do_handle("reject_friend_request", %{"user_id" => user_id}, state) - when is_integer(user_id) do - Account.decline_friend_request(user_id, state.userid) - state - end - - def do_handle("remove_friend", %{"user_id" => user_id}, state) when is_integer(user_id) do - Account.delete_friend(state.userid, user_id) - state - end - - def do_handle(cmd, data, state) do - reply( - :system, - :error, - %{ - location: "auth.handle", - error: "No match for cmd: '#{cmd}' with data '#{Kernel.inspect(data)}'" - }, - state - ) - end -end diff --git a/lib/teiserver/protocols/tachyon_v1/user_out.ex b/lib/teiserver/protocols/tachyon_v1/user_out.ex deleted file mode 100644 index 6812d4a51..000000000 --- a/lib/teiserver/protocols/tachyon_v1/user_out.ex +++ /dev/null @@ -1,54 +0,0 @@ -defmodule Teiserver.Protocols.Tachyon.V1.UserOut do - @spec do_reply(atom(), any) :: Map.t() - def do_reply(:user_list, {users, clients}) do - %{ - cmd: "s.user.user_list", - users: users, - clients: clients - } - end - - def do_reply(:user_list, users) do - %{ - cmd: "s.user.user_list", - users: users - } - end - - def do_reply(:list_friend_ids, {friend_ids, request_ids}) do - %{ - cmd: "s.user.list_friend_ids", - friend_id_list: friend_ids, - request_id_list: request_ids - } - end - - def do_reply(:list_friend_users_and_clients, {users, clients}) do - %{ - cmd: "s.user.list_friend_users_and_clients", - user_list: users, - client_list: clients - } - end - - def do_reply(:friend_added, friend_id) do - %{ - cmd: "s.user.friend_added", - user_id: friend_id - } - end - - def do_reply(:friend_removed, friend_id) do - %{ - cmd: "s.user.friend_removed", - user_id: friend_id - } - end - - def do_reply(:friend_request, requester_id) do - %{ - cmd: "s.user.friend_request", - user_id: requester_id - } - end -end diff --git a/lib/teiserver/servers/telemetry_server.ex b/lib/teiserver/servers/telemetry_server.ex index 225dcb9b5..e67c24146 100644 --- a/lib/teiserver/servers/telemetry_server.ex +++ b/lib/teiserver/servers/telemetry_server.ex @@ -37,9 +37,6 @@ defmodule Teiserver.Telemetry.TelemetryServer do spring_server_messages_sent: 0, spring_server_batches_sent: 0, spring_client_messages_sent: 0, - tachyon_server_messages_sent: 0, - tachyon_server_batches_sent: 0, - tachyon_client_messages_sent: 0, login_queue_length: 0 } @@ -70,18 +67,6 @@ defmodule Teiserver.Telemetry.TelemetryServer do }} end - def handle_cast( - {:tachyon_messages_sent, _userid, server_count, _batch_count, client_count}, - state - ) do - {:noreply, - %{ - state - | tachyon_server_messages_sent: state.tachyon_server_messages_sent + server_count, - tachyon_client_messages_sent: state.tachyon_client_messages_sent + client_count - }} - end - def handle_cast({:matchmaking_update, queue_id, data}, %{matchmaking: matchmaking} = state) do new_matchmaking = Map.put(matchmaking, queue_id, data) {:noreply, %{state | matchmaking: new_matchmaking}} @@ -226,9 +211,6 @@ defmodule Teiserver.Telemetry.TelemetryServer do spring_server_messages_sent: state.spring_server_messages_sent, spring_server_batches_sent: state.spring_server_batches_sent, spring_client_messages_sent: state.spring_client_messages_sent, - tachyon_server_messages_sent: state.tachyon_server_messages_sent, - tachyon_server_batches_sent: state.tachyon_server_batches_sent, - tachyon_client_messages_sent: state.tachyon_client_messages_sent, login_queue_length: login_queue_length, os_mon: get_os_mon_data() } diff --git a/lib/teiserver/tcp/tachyon/tachyon_tcp_server.ex b/lib/teiserver/tcp/tachyon/tachyon_tcp_server.ex deleted file mode 100644 index 2dfd8f104..000000000 --- a/lib/teiserver/tcp/tachyon/tachyon_tcp_server.ex +++ /dev/null @@ -1,566 +0,0 @@ -defmodule Teiserver.TachyonTcpServer do - @moduledoc false - use GenServer - require Logger - alias Phoenix.PubSub - alias Teiserver.Config - import Teiserver.Helper.NumberHelper, only: [int_parse: 1] - - alias Teiserver.{CacheUser, Client, Account} - alias Teiserver.Data.Types, as: T - - @behaviour :ranch_protocol - @spec get_ssl_opts :: [ - {:cacertfile, String.t()} | {:certfile, String.t()} | {:keyfile, String.t()} - ] - def get_ssl_opts() do - {certfile, cacertfile, keyfile} = { - Application.get_env(:teiserver, Teiserver)[:certs][:certfile], - Application.get_env(:teiserver, Teiserver)[:certs][:cacertfile], - Application.get_env(:teiserver, Teiserver)[:certs][:keyfile] - } - - [ - certfile: certfile, - cacertfile: cacertfile, - keyfile: keyfile - ] - end - - # Called at startup - def start_link(_opts) do - ssl_opts = get_ssl_opts() - - :ranch.start_listener( - make_ref(), - :ranch_ssl, - ssl_opts ++ - [ - max_connections: :infinity, - port: Application.get_env(:teiserver, Teiserver)[:ports][:tachyon] - ], - __MODULE__, - [] - ) - end - - # Called on new connection - @impl true - def start_link(ref, socket, transport, _opts) do - pid = :proc_lib.spawn_link(__MODULE__, :init, [ref, socket, transport]) - {:ok, pid} - end - - def init(ref, socket, transport) do - {:ok, {ip, _}} = transport.peername(socket) - - ip = - ip - |> Tuple.to_list() - |> Enum.join(".") - - :ranch.accept_ack(ref) - transport.setopts(socket, [{:active, true}]) - - heartbeat = Application.get_env(:teiserver, Teiserver)[:heartbeat_interval] - - if heartbeat do - :timer.send_interval(heartbeat, self(), :heartbeat) - end - - :timer.send_interval(60_000, self(), :message_count) - - state = %{ - # Connection state - message_part: "", - last_msg: System.system_time(:second), - socket: socket, - transport: transport, - ip: ip, - protocol: Application.get_env(:teiserver, Teiserver)[:default_tachyon_protocol], - protocol_in: - Application.get_env(:teiserver, Teiserver)[:default_tachyon_protocol].protocol_in(), - protocol_out: - Application.get_env(:teiserver, Teiserver)[:default_tachyon_protocol].protocol_out(), - - # Client state - userid: nil, - username: nil, - lobby_host: false, - queues: [], - - # Connection microstate - msg_id: nil, - lobby_id: nil, - party_id: nil, - party_role: nil, - print_client_messages: false, - print_server_messages: false, - script_password: nil, - exempt_from_cmd_throttle: true, - cmd_timestamps: [], - - # Caching app configs - flood_rate_limit_count: - Config.get_site_config_cache("teiserver.Tachyon flood rate limit count"), - flood_rate_window_size: - Config.get_site_config_cache("teiserver.Tachyon flood rate window size"), - server_messages: 0, - server_batches: 0, - client_messages: 0 - } - - :ok = PubSub.subscribe(Teiserver.PubSub, "teiserver_server") - - :gen_server.enter_loop(__MODULE__, [], state) - end - - @impl true - def init(init_arg) do - {:ok, init_arg} - end - - @impl true - @spec handle_call(any(), any(), T.tachyon_tcp_state()) :: {:reply, any(), T.tachyon_tcp_state()} - def handle_call({:get, key}, _from, state) do - {:reply, Map.get(state, key), state} - end - - @impl true - @spec handle_info(any(), T.tachyon_tcp_state()) :: {:noreply, T.tachyon_tcp_state()} - def handle_info({:put, key, value}, state) do - new_state = Map.put(state, key, value) - {:noreply, new_state} - end - - def handle_info(:message_count, state) do - Teiserver.Telemetry.cast_to_server({ - :spring_messages_sent, - state.userid, - state.server_messages, - state.server_batches, - state.client_messages - }) - - {:noreply, %{state | server_messages: 0, client_messages: 0, server_batches: 0}} - end - - # If Ctrl + C is sent through it kills the connection, makes telnet debugging easier - def handle_info({_, _socket, <<255, 244, 255, 253, 6>>}, state) do - Client.disconnect(state.userid, "Terminal exit command") - send(self(), :terminate) - {:noreply, state} - end - - def handle_info({:login_accepted, userid}, state) do - user = Account.get_user_by_id(userid) - send(self(), {:action, {:login_accepted, user}}) - Teiserver.Protocols.Tachyon.V1.TachyonOut.reply(:auth, :login, {:success, user}, state) - - {:noreply, state} - end - - # Instructions to update the state of the connection - def handle_info({:action, {action_type, data}}, state) do - new_state = - case {action_type, data} do - {:login_accepted, user_data} -> - state.protocol.do_action(:login_accepted, user_data, state) - - {:host_lobby, lobby_id} -> - state.protocol.do_action(:host_lobby, lobby_id, state) - - {:join_lobby, lobby_id} -> - state.protocol.do_action(:join_lobby, lobby_id, state) - - {:leave_lobby, lobby_id} -> - state.protocol.do_action(:leave_lobby, lobby_id, state) - - {:watch_channel, channel} -> - state.protocol.do_action(:watch_channel, channel, state) - - {:unwatch_channel, channel} -> - state.protocol.do_action(:unwatch_channel, channel, state) - - {:lead_party, party_id} -> - state.protocol.do_action(:lead_party, party_id, state) - - {:join_party, party_id} -> - state.protocol.do_action(:join_party, party_id, state) - - {:leave_party, party_id} -> - state.protocol.do_action(:leave_party, party_id, state) - - {:set_script_password, new_script_password} -> - %{state | script_password: new_script_password} - - # Matchmaking - {:joined_queue, queue_id} -> - state.protocol.do_action(:joined_queue, queue_id, state) - - {:left_queue, queue_id} -> - state.protocol.do_action(:left_queue, queue_id, state) - end - - {:noreply, new_state} - end - - # Main source of data ingress - def handle_info({:ssl, _socket, data}, state) do - data = to_string(data) - - case flood_protect?(data, state) do - {true, state} -> - engage_flood_protection(state) - - {false, state} -> - new_state = state.protocol_in.data_in(to_string(data), state) - {:noreply, new_state} - end - end - - # Email, when an email is sent we get a message, we don't care about that for the most part (yet) - def handle_info({:delivered_email, _email}, state) do - {:noreply, state} - end - - # Heartbeat allows us to kill stale connections - def handle_info(:heartbeat, state) do - diff = System.system_time(:second) - state.last_msg - - if diff > Application.get_env(:teiserver, Teiserver)[:heartbeat_timeout] do - if state.username do - Logger.info("Heartbeat timeout for #{state.username}") - end - - {:stop, :normal, state} - else - {:noreply, state} - end - end - - # User updates - def handle_info(%{channel: "teiserver_user_updates:" <> _} = data, state) do - case data.event do - :update_report -> - :ok - - :friend_request -> - state.protocol_out.reply(:user, :friend_request, data.requester_id, state) - - :friend_added -> - state.protocol_out.reply(:user, :friend_added, data.friend_id, state) - - :friend_removed -> - state.protocol_out.reply(:user, :friend_removed, data.friend_id, state) - - _ -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line}\nNo handler for event type #{data.event}" - ) - end - - {:noreply, state} - end - - # Depreciated/depreciating stuff, we just ignore it - def handle_info({:request_user_join_lobby, _}, state), do: {:noreply, state} - def handle_info({:join_battle_request_response, _, _, _}, state), do: {:noreply, state} - def handle_info({:force_join_battle, _, _}, state), do: {:noreply, state} - - # Internal pubsub messaging (see pubsub.md) - def handle_info(%{channel: "teiserver_public_stats", data: data}, state) do - state.protocol_out.reply(:system, :server_stats, data, state) - {:noreply, state} - end - - def handle_info(%{channel: "teiserver_server", event: event, node: node}, state) do - state.protocol_out.reply(:system, :server_event, {event, node}, state) - {:noreply, state} - end - - def handle_info(data = %{channel: "teiserver_party:" <> party_id, event: event}, state) do - case event do - :updated_values -> - state.protocol_out.reply(:party, :updated, {party_id, data.new_values}, state) - - :message -> - state.protocol_out.reply(:party, :message, {data.sender_id, data.message}, state) - - :closed -> - state - - _ -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line}\nNo handler for event type #{data.event}" - ) - end - - {:noreply, state} - end - - def handle_info( - %{channel: "teiserver_lobby_host_message:" <> lobby_id, event: event} = data, - state - ) do - lobby_id = int_parse(lobby_id) - - new_state = - if state.lobby_host == true and state.lobby_id == lobby_id do - case event do - :user_requests_to_join -> - state.protocol_out.reply( - :lobby_host, - data.event, - {data.userid, data.script_password}, - state - ) - - _ -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line}\nNo handler for event type #{data.event}" - ) - end - else - state - end - - {:noreply, new_state} - end - - def handle_info(%{channel: "teiserver_lobby_chat:" <> _} = event, state) do - {:noreply, - state.protocol_out.reply( - :lobby_chat, - event.event, - {event.lobby_id, event.userid, event.message}, - state - )} - end - - def handle_info(%{channel: "teiserver_lobby_updates"} = msg, state) do - {:noreply, state.protocol_out.reply(:lobby, msg.event, msg, state)} - end - - def handle_info(%{channel: "teiserver_global_lobby_updates"} = data, state) do - new_state = - case data.event do - :opened -> - state.protocol_out.reply(:lobby, :opened, data, state) - - :closed -> - state.protocol_out.reply(:lobby, :closed, data, state) - - :updated_values -> - state.protocol_out.reply( - :lobby, - :update_values, - data, - state - ) - - _ -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line}\nNo handler for teiserver_global_lobby_updates.event = #{data.event}" - ) - - state - end - - {:noreply, new_state} - end - - def handle_info(%{channel: "teiserver_client_watch:" <> userid_str} = data, state) do - userid = int_parse(userid_str) - - if state.userid != userid do - case data.event do - :connected -> - state.protocol_out.reply(:client, :connected, userid, state) - - :disconnected -> - state.protocol_out.reply(:client, :disconnected, userid, state) - - :added_to_party -> - state.protocol_out.reply(:client, :added_to_party, {userid, data.party_id}, state) - - :left_party -> - state.protocol_out.reply(:client, :left_party, {userid, data.party_id}, state) - - :added_to_lobby -> - state.protocol_out.reply(:client, :added_to_lobby, {userid, data.lobby_id}, state) - - :left_lobby -> - state.protocol_out.reply(:client, :left_lobby, {userid, data.lobby_id}, state) - - _ -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line}\nNo handler for teiserver_global_lobby_updates.event = #{data.event}" - ) - - state - end - end - - {:noreply, state} - end - - def handle_info(%{channel: "teiserver_client_messages:" <> userid_str} = data, state) do - userid = int_parse(userid_str) - - if state.userid == userid do - case data.event do - :join_lobby_request_response -> - case data.response do - :accept -> - # state.protocol_out.reply(:lobby, data.event, {data.lobby_id, :accept, state.script_password}, state) - send(self(), {:action, {:join_lobby, data.lobby_id}}) - - # state.protocol_out.reply(:lobby, :joined, {data.lobby_id, state.script_password}, state) - state - - :deny -> - state.protocol_out.reply( - :lobby, - data.event, - {data.lobby_id, :deny, data.reason}, - state - ) - end - - :force_join_lobby -> - send(self(), {:action, {:join_lobby, data.lobby_id}}) - - state.protocol_out.reply( - :lobby, - data.event, - {data.lobby_id, data.script_password}, - state - ) - - :added_to_lobby -> - send(self(), {:action, {:join_lobby, data.lobby_id}}) - state.protocol_out.reply(:lobby, :joined, {data.lobby_id, data.script_password}, state) - - :received_direct_message -> - state.protocol_out.reply( - :communication, - data.event, - {data.sender_id, data.message_content}, - state - ) - - :lobby_direct_announce -> - state.protocol_out.reply( - :lobby, - :received_lobby_direct_announce, - {data.sender_id, data.message_content}, - state - ) - - :matchmaking -> - case data.sub_event do - :joined_queue -> - send(self(), {:action, {:joined_queue, data.queue_id}}) - state.protocol_out.reply(:matchmaking, :join_queue_success, data.queue_id, state) - - :left_queue -> - send(self(), {:action, {:left_queue, data.queue_id}}) - state - - _ -> - state.protocol_out.reply( - :matchmaking, - data.sub_event, - {data.queue_id, data.match_id}, - state - ) - end - - :party_invite -> - state.protocol_out.reply(:party, :invite, data.party_id, state) - - :added_to_party -> - send(self(), {:action, {:join_party, data.party_id}}) - state.protocol_out.reply(:party, :added_to, data.party_id, state) - - :left_party -> - send(self(), {:action, {:leave_party, data.party_id}}) - state.protocol_out.reply(:party, :left_party, data.party_id, state) - - :disconnected -> - send(self(), :terminate) - state - - :client_updated -> - state - - _ -> - Logger.error( - "Error at: #{__ENV__.file}:#{__ENV__.line}\nNo handler for event type #{data.event}\nFull data: #{Kernel.inspect(data)}" - ) - - state - end - end - - {:noreply, state} - end - - # Connection - def handle_info({:ssl_closed, socket}, %{socket: socket, transport: transport} = state) do - transport.close(socket) - Client.disconnect(state.userid, ":ssl_closed with socket") - {:stop, :normal, %{state | userid: nil}} - end - - def handle_info({:ssl_closed, _socket}, state) do - Client.disconnect(state.userid, ":ssl_closed no socket") - {:stop, :normal, %{state | userid: nil}} - end - - def handle_info(:terminate, state) do - Client.disconnect(state.userid, "tcp_server :terminate") - {:stop, :normal, %{state | userid: nil}} - end - - @impl true - def terminate(_reason, state) do - Client.disconnect(state.userid, "tcp_server terminate") - end - - # Internal functions - @spec flood_protect?(String.t(), map()) :: {boolean, map()} - defp flood_protect?(_, %{exempt_from_cmd_throttle: true} = state), do: {false, state} - - defp flood_protect?(data, state) do - cmd_timestamps = - if String.contains?(data, "\n") do - now = System.system_time(:second) - limiter = now - state.flood_rate_window_size - - [now | state.cmd_timestamps] - |> Enum.filter(fn cmd_ts -> cmd_ts > limiter end) - else - state.cmd_timestamps - end - - if Enum.count(cmd_timestamps) > state.flood_rate_limit_count do - {true, %{state | cmd_timestamps: cmd_timestamps}} - else - {false, %{state | cmd_timestamps: cmd_timestamps}} - end - end - - defp engage_flood_protection(state) do - state.protocol_out.reply(:disconnect, "Flood protection", nil, state) - CacheUser.set_flood_level(state.userid, 10) - Client.disconnect(state.userid, "TachyonTCPServer.flood_protection") - - Logger.error( - "Tachyon command overflow from #{state.username}/#{state.userid} with #{Enum.count(state.cmd_timestamps)} commands. Disconnected and flood protection engaged." - ) - - {:stop, "Flood protection", state} - end -end diff --git a/lib/teiserver_web/controllers/api/hailstorm_controller.ex b/lib/teiserver_web/controllers/api/hailstorm_controller.ex index 91f9138b6..2be344c2d 100644 --- a/lib/teiserver_web/controllers/api/hailstorm_controller.ex +++ b/lib/teiserver_web/controllers/api/hailstorm_controller.ex @@ -13,8 +13,6 @@ defmodule TeiserverWeb.API.HailstormController do @spec start(Plug.Conn.t(), map()) :: Plug.Conn.t() def start(conn, _params) do - Teiserver.Tachyon.CommandDispatch.build_dispatch_cache() - conn |> put_status(201) |> assign(:result, %{up: true}) diff --git a/lib/teiserver_web/endpoint.ex b/lib/teiserver_web/endpoint.ex index 6a4b36469..306249985 100644 --- a/lib/teiserver_web/endpoint.ex +++ b/lib/teiserver_web/endpoint.ex @@ -16,14 +16,6 @@ defmodule TeiserverWeb.Endpoint do longpoll: false ) - socket("/tachyon", Teiserver.Tachyon.TachyonSocket, - websocket: [ - connect_info: [:peer_data, :x_headers, :user_agent], - error_handler: {Teiserver.Tachyon.TachyonSocket, :handle_error, []} - ], - longpoll: false - ) - # Serve at "/" the static files from "priv/static" directory. # # You should set gzip to true if you are running phx.digest diff --git a/lib/teiserver_web/router.ex b/lib/teiserver_web/router.ex index e73d3e614..a4afbd42c 100644 --- a/lib/teiserver_web/router.ex +++ b/lib/teiserver_web/router.ex @@ -414,14 +414,6 @@ defmodule TeiserverWeb.Router do end # API - scope "/tachyon", TeiserverWeb.API do - pipe_through :api - post "/login", SessionController, :login - post "/register", SessionController, :register - post "/request_token", SessionController, :request_token - get "/request_token", SessionController, :request_token_get - end - scope "/teiserver/api", TeiserverWeb.API do pipe_through :api post "/login", SessionController, :login diff --git a/mix.exs b/mix.exs index 2253c9279..ae2c898e5 100644 --- a/mix.exs +++ b/mix.exs @@ -43,6 +43,7 @@ defmodule Teiserver.MixProject do # Specifies which paths to compile per environment. defp elixirc_paths(:test), do: ["lib", "test/support"] + defp elixirc_paths(:dev), do: ["lib", "test/support"] defp elixirc_paths(_), do: ["lib"] # Run "mix help deps" to learn about dependencies. diff --git a/priv/tachyon/schema_v1/account/acceptFriendRequest/request.json b/priv/tachyon/schema_v1/account/acceptFriendRequest/request.json deleted file mode 100644 index ed23643fb..000000000 --- a/priv/tachyon/schema_v1/account/acceptFriendRequest/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/acceptFriendRequest/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/acceptFriendRequest/response.json b/priv/tachyon/schema_v1/account/acceptFriendRequest/response.json deleted file mode 100644 index 52da0ce82..000000000 --- a/priv/tachyon/schema_v1/account/acceptFriendRequest/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/acceptFriendRequest/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/acceptFriendRequest/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/addFriend/request.json b/priv/tachyon/schema_v1/account/addFriend/request.json deleted file mode 100644 index 6627f492b..000000000 --- a/priv/tachyon/schema_v1/account/addFriend/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/addFriend/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/addFriend/response.json b/priv/tachyon/schema_v1/account/addFriend/response.json deleted file mode 100644 index a009af0fa..000000000 --- a/priv/tachyon/schema_v1/account/addFriend/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/addFriend/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/addFriend/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/getFriends/request.json b/priv/tachyon/schema_v1/account/getFriends/request.json deleted file mode 100644 index 8b4e94dd5..000000000 --- a/priv/tachyon/schema_v1/account/getFriends/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/getFriends/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/getFriends/response.json b/priv/tachyon/schema_v1/account/getFriends/response.json deleted file mode 100644 index e849ce794..000000000 --- a/priv/tachyon/schema_v1/account/getFriends/response.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "properties": { - "userClients": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "number" - }, - "name": { - "type": "string" - }, - "isBot": { - "type": "boolean" - }, - "clanId": { - "type": [ - "number", - "null" - ] - }, - "icons": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - }, - "battleStatus": { - "anyOf": [ - { - "type": "object", - "properties": { - "lobbyId": { - "type": [ - "number", - "null" - ] - }, - "inGame": { - "type": "boolean" - }, - "away": { - "type": "boolean" - }, - "ready": { - "type": "boolean" - }, - "playerNumber": { - "type": [ - "number", - "null" - ] - }, - "teamColour": { - "type": [ - "string", - "null" - ] - }, - "isPlayer": { - "type": "boolean" - }, - "bonus": { - "type": "number" - }, - "sync": { - "type": "object", - "properties": { - "engine": { - "type": "number" - }, - "game": { - "type": "number" - }, - "map": { - "type": "number" - } - }, - "required": [ - "engine", - "game", - "map" - ] - }, - "partyId": { - "type": [ - "string", - "null" - ] - }, - "clanTag": { - "type": [ - "string", - "null" - ] - }, - "muted": { - "type": "boolean" - } - }, - "required": [ - "lobbyId", - "inGame", - "away", - "ready", - "playerNumber", - "teamColour", - "isPlayer", - "bonus", - "sync", - "partyId", - "clanTag", - "muted" - ] - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "id", - "name", - "isBot", - "clanId", - "icons", - "roles", - "battleStatus" - ] - } - } - }, - "required": [ - "userClients" - ] - }, - "command": { - "type": "string", - "const": "account/getFriends/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/getFriends/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/getUserClients/request.json b/priv/tachyon/schema_v1/account/getUserClients/request.json deleted file mode 100644 index fc1940590..000000000 --- a/priv/tachyon/schema_v1/account/getUserClients/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/getUserClients/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/getUserClients/response.json b/priv/tachyon/schema_v1/account/getUserClients/response.json deleted file mode 100644 index fb118a668..000000000 --- a/priv/tachyon/schema_v1/account/getUserClients/response.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "properties": { - "userClients": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "number" - }, - "name": { - "type": "string" - }, - "isBot": { - "type": "boolean" - }, - "clanId": { - "type": [ - "number", - "null" - ] - }, - "icons": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - }, - "battleStatus": { - "anyOf": [ - { - "type": "object", - "properties": { - "lobbyId": { - "type": [ - "number", - "null" - ] - }, - "inGame": { - "type": "boolean" - }, - "away": { - "type": "boolean" - }, - "ready": { - "type": "boolean" - }, - "playerNumber": { - "type": [ - "number", - "null" - ] - }, - "teamColour": { - "type": [ - "string", - "null" - ] - }, - "isPlayer": { - "type": "boolean" - }, - "bonus": { - "type": "number" - }, - "sync": { - "type": "object", - "properties": { - "engine": { - "type": "number" - }, - "game": { - "type": "number" - }, - "map": { - "type": "number" - } - }, - "required": [ - "engine", - "game", - "map" - ] - }, - "partyId": { - "type": [ - "string", - "null" - ] - }, - "clanTag": { - "type": [ - "string", - "null" - ] - }, - "muted": { - "type": "boolean" - } - }, - "required": [ - "lobbyId", - "inGame", - "away", - "ready", - "playerNumber", - "teamColour", - "isPlayer", - "bonus", - "sync", - "partyId", - "clanTag", - "muted" - ] - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "id", - "name", - "isBot", - "clanId", - "icons", - "roles", - "battleStatus" - ] - } - } - }, - "required": [ - "userClients" - ] - }, - "command": { - "type": "string", - "const": "account/getUserClients/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/getUserClients/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/receivedFriendRequest/response.json b/priv/tachyon/schema_v1/account/receivedFriendRequest/response.json deleted file mode 100644 index 49f428da0..000000000 --- a/priv/tachyon/schema_v1/account/receivedFriendRequest/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/receivedFriendRequest/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/receivedFriendRequest/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/rejectFriendRequest/request.json b/priv/tachyon/schema_v1/account/rejectFriendRequest/request.json deleted file mode 100644 index 361489bbd..000000000 --- a/priv/tachyon/schema_v1/account/rejectFriendRequest/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/rejectFriendRequest/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/rejectFriendRequest/response.json b/priv/tachyon/schema_v1/account/rejectFriendRequest/response.json deleted file mode 100644 index cd94eb150..000000000 --- a/priv/tachyon/schema_v1/account/rejectFriendRequest/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/rejectFriendRequest/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/rejectFriendRequest/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/removeFriend/request.json b/priv/tachyon/schema_v1/account/removeFriend/request.json deleted file mode 100644 index e99427825..000000000 --- a/priv/tachyon/schema_v1/account/removeFriend/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/removeFriend/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/removeFriend/response.json b/priv/tachyon/schema_v1/account/removeFriend/response.json deleted file mode 100644 index 9134586fc..000000000 --- a/priv/tachyon/schema_v1/account/removeFriend/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/removeFriend/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/removeFriend/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/rescindFriendRequest/request.json b/priv/tachyon/schema_v1/account/rescindFriendRequest/request.json deleted file mode 100644 index 4e9fcc9e4..000000000 --- a/priv/tachyon/schema_v1/account/rescindFriendRequest/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/rescindFriendRequest/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/rescindFriendRequest/response.json b/priv/tachyon/schema_v1/account/rescindFriendRequest/response.json deleted file mode 100644 index 0e245dd3e..000000000 --- a/priv/tachyon/schema_v1/account/rescindFriendRequest/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/rescindFriendRequest/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/rescindFriendRequest/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/updateAccount/request.json b/priv/tachyon/schema_v1/account/updateAccount/request.json deleted file mode 100644 index 178401351..000000000 --- a/priv/tachyon/schema_v1/account/updateAccount/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/updateAccount/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/updateAccount/response.json b/priv/tachyon/schema_v1/account/updateAccount/response.json deleted file mode 100644 index aceddd8be..000000000 --- a/priv/tachyon/schema_v1/account/updateAccount/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/updateAccount/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/updateAccount/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/whoAmI/request.json b/priv/tachyon/schema_v1/account/whoAmI/request.json deleted file mode 100644 index 050419d25..000000000 --- a/priv/tachyon/schema_v1/account/whoAmI/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "account/whoAmI/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/account/whoAmI/response.json b/priv/tachyon/schema_v1/account/whoAmI/response.json deleted file mode 100644 index 2393ad7a7..000000000 --- a/priv/tachyon/schema_v1/account/whoAmI/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "account/whoAmI/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "account/whoAmI/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/auth/getToken/request.json b/priv/tachyon/schema_v1/auth/getToken/request.json deleted file mode 100644 index 3b77613ff..000000000 --- a/priv/tachyon/schema_v1/auth/getToken/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "auth/getToken/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/auth/getToken/response.json b/priv/tachyon/schema_v1/auth/getToken/response.json deleted file mode 100644 index 3dcf8c2d1..000000000 --- a/priv/tachyon/schema_v1/auth/getToken/response.json +++ /dev/null @@ -1,220 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "properties": { - "user": { - "type": "object", - "properties": { - "permissions": { - "type": "array", - "items": { - "type": "string" - } - }, - "friends": { - "type": "array", - "items": { - "type": "number" - } - }, - "friend_requests": { - "type": "array", - "items": { - "type": "number" - } - }, - "ignores": { - "type": "array", - "items": { - "type": "number" - } - }, - "id": { - "type": "number" - }, - "name": { - "type": "string" - }, - "isBot": { - "type": "boolean" - }, - "clanId": { - "type": [ - "number", - "null" - ] - }, - "icons": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "roles": { - "type": "array", - "items": { - "type": "string" - } - }, - "battleStatus": { - "anyOf": [ - { - "type": "object", - "properties": { - "lobbyId": { - "type": [ - "number", - "null" - ] - }, - "inGame": { - "type": "boolean" - }, - "away": { - "type": "boolean" - }, - "ready": { - "type": "boolean" - }, - "playerNumber": { - "type": [ - "number", - "null" - ] - }, - "teamColour": { - "type": [ - "string", - "null" - ] - }, - "isPlayer": { - "type": "boolean" - }, - "bonus": { - "type": "number" - }, - "sync": { - "type": "object", - "properties": { - "engine": { - "type": "number" - }, - "game": { - "type": "number" - }, - "map": { - "type": "number" - } - }, - "required": [ - "engine", - "game", - "map" - ] - }, - "partyId": { - "type": [ - "string", - "null" - ] - }, - "clanTag": { - "type": [ - "string", - "null" - ] - }, - "muted": { - "type": "boolean" - } - }, - "required": [ - "lobbyId", - "inGame", - "away", - "ready", - "playerNumber", - "teamColour", - "isPlayer", - "bonus", - "sync", - "partyId", - "clanTag", - "muted" - ] - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "battleStatus", - "clanId", - "friend_requests", - "friends", - "icons", - "id", - "ignores", - "isBot", - "name", - "permissions", - "roles" - ] - } - }, - "required": [ - "user" - ] - }, - "command": { - "type": "string", - "const": "auth/getToken/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "enum": [ - "internal_error", - "no_user_found", - "invalid_password", - "max_attempts", - "banned" - ] - }, - "command": { - "type": "string", - "const": "auth/getToken/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/auth/register/request.json b/priv/tachyon/schema_v1/auth/register/request.json deleted file mode 100644 index 8e48853c4..000000000 --- a/priv/tachyon/schema_v1/auth/register/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "auth/register/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/auth/register/response.json b/priv/tachyon/schema_v1/auth/register/response.json deleted file mode 100644 index 97d603547..000000000 --- a/priv/tachyon/schema_v1/auth/register/response.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "auth/register/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "enum": [ - "internal_error", - "email_taken", - "username_taken", - "invalid_email", - "weak_password", - "username_profanity" - ] - }, - "command": { - "type": "string", - "const": "auth/register/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/acceptInvite/request.json b/priv/tachyon/schema_v1/clan/acceptInvite/request.json deleted file mode 100644 index d009eaf6c..000000000 --- a/priv/tachyon/schema_v1/clan/acceptInvite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "clan/acceptInvite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/acceptInvite/response.json b/priv/tachyon/schema_v1/clan/acceptInvite/response.json deleted file mode 100644 index 51a03c104..000000000 --- a/priv/tachyon/schema_v1/clan/acceptInvite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "clan/acceptInvite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "clan/acceptInvite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/getClan/request.json b/priv/tachyon/schema_v1/clan/getClan/request.json deleted file mode 100644 index 7dbeb145b..000000000 --- a/priv/tachyon/schema_v1/clan/getClan/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "clan/getClan/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/getClan/response.json b/priv/tachyon/schema_v1/clan/getClan/response.json deleted file mode 100644 index 83666c1bc..000000000 --- a/priv/tachyon/schema_v1/clan/getClan/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "clan/getClan/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "clan/getClan/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/getClans/request.json b/priv/tachyon/schema_v1/clan/getClans/request.json deleted file mode 100644 index dc8fe6749..000000000 --- a/priv/tachyon/schema_v1/clan/getClans/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "clan/getClans/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/getClans/response.json b/priv/tachyon/schema_v1/clan/getClans/response.json deleted file mode 100644 index 9570b727a..000000000 --- a/priv/tachyon/schema_v1/clan/getClans/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "clan/getClans/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "clan/getClans/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/invite/request.json b/priv/tachyon/schema_v1/clan/invite/request.json deleted file mode 100644 index 15a356f41..000000000 --- a/priv/tachyon/schema_v1/clan/invite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "clan/invite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/invite/response.json b/priv/tachyon/schema_v1/clan/invite/response.json deleted file mode 100644 index 0b6d9173e..000000000 --- a/priv/tachyon/schema_v1/clan/invite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "clan/invite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "clan/invite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/rejectInvite/request.json b/priv/tachyon/schema_v1/clan/rejectInvite/request.json deleted file mode 100644 index 0a1cbf3e1..000000000 --- a/priv/tachyon/schema_v1/clan/rejectInvite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "clan/rejectInvite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/rejectInvite/response.json b/priv/tachyon/schema_v1/clan/rejectInvite/response.json deleted file mode 100644 index d4df79e3d..000000000 --- a/priv/tachyon/schema_v1/clan/rejectInvite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "clan/rejectInvite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "clan/rejectInvite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/rescindInvite/request.json b/priv/tachyon/schema_v1/clan/rescindInvite/request.json deleted file mode 100644 index 1b34afbf6..000000000 --- a/priv/tachyon/schema_v1/clan/rescindInvite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "clan/rescindInvite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/clan/rescindInvite/response.json b/priv/tachyon/schema_v1/clan/rescindInvite/response.json deleted file mode 100644 index 8bd2add28..000000000 --- a/priv/tachyon/schema_v1/clan/rescindInvite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "clan/rescindInvite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "clan/rescindInvite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/communication/getNotifications/request.json b/priv/tachyon/schema_v1/communication/getNotifications/request.json deleted file mode 100644 index 427dc6e09..000000000 --- a/priv/tachyon/schema_v1/communication/getNotifications/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "communication/getNotifications/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/communication/getNotifications/response.json b/priv/tachyon/schema_v1/communication/getNotifications/response.json deleted file mode 100644 index ba26a7c3e..000000000 --- a/priv/tachyon/schema_v1/communication/getNotifications/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "communication/getNotifications/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "communication/getNotifications/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/communication/receivedDirectMessage/response.json b/priv/tachyon/schema_v1/communication/receivedDirectMessage/response.json deleted file mode 100644 index 31e867f56..000000000 --- a/priv/tachyon/schema_v1/communication/receivedDirectMessage/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "communication/receivedDirectMessage/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "communication/receivedDirectMessage/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/communication/sendDirectMessage/request.json b/priv/tachyon/schema_v1/communication/sendDirectMessage/request.json deleted file mode 100644 index 9e83246cd..000000000 --- a/priv/tachyon/schema_v1/communication/sendDirectMessage/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "communication/sendDirectMessage/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/communication/sendDirectMessage/response.json b/priv/tachyon/schema_v1/communication/sendDirectMessage/response.json deleted file mode 100644 index fcb91156c..000000000 --- a/priv/tachyon/schema_v1/communication/sendDirectMessage/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "communication/sendDirectMessage/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "communication/sendDirectMessage/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getGame/request.json b/priv/tachyon/schema_v1/config/getGame/request.json deleted file mode 100644 index 887133b69..000000000 --- a/priv/tachyon/schema_v1/config/getGame/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "config/getGame/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getGame/response.json b/priv/tachyon/schema_v1/config/getGame/response.json deleted file mode 100644 index 32fd670be..000000000 --- a/priv/tachyon/schema_v1/config/getGame/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "config/getGame/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "config/getGame/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getGameTypes/request.json b/priv/tachyon/schema_v1/config/getGameTypes/request.json deleted file mode 100644 index 50144e894..000000000 --- a/priv/tachyon/schema_v1/config/getGameTypes/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "config/getGameTypes/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getGameTypes/response.json b/priv/tachyon/schema_v1/config/getGameTypes/response.json deleted file mode 100644 index b3b9f68c6..000000000 --- a/priv/tachyon/schema_v1/config/getGameTypes/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "config/getGameTypes/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "config/getGameTypes/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getUserClient/request.json b/priv/tachyon/schema_v1/config/getUserClient/request.json deleted file mode 100644 index b33d064a8..000000000 --- a/priv/tachyon/schema_v1/config/getUserClient/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "config/getUserClient/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getUserClient/response.json b/priv/tachyon/schema_v1/config/getUserClient/response.json deleted file mode 100644 index c309f7487..000000000 --- a/priv/tachyon/schema_v1/config/getUserClient/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "config/getUserClient/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "config/getUserClient/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getUserClientTypes/request.json b/priv/tachyon/schema_v1/config/getUserClientTypes/request.json deleted file mode 100644 index 60ea9cbee..000000000 --- a/priv/tachyon/schema_v1/config/getUserClientTypes/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "config/getUserClientTypes/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/getUserClientTypes/response.json b/priv/tachyon/schema_v1/config/getUserClientTypes/response.json deleted file mode 100644 index 7ae49becc..000000000 --- a/priv/tachyon/schema_v1/config/getUserClientTypes/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "config/getUserClientTypes/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "config/getUserClientTypes/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/setGame/response.json b/priv/tachyon/schema_v1/config/setGame/response.json deleted file mode 100644 index b558b9dd0..000000000 --- a/priv/tachyon/schema_v1/config/setGame/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "config/setGame/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "config/setGame/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/config/setUserClient/response.json b/priv/tachyon/schema_v1/config/setUserClient/response.json deleted file mode 100644 index 7007fdb7e..000000000 --- a/priv/tachyon/schema_v1/config/setUserClient/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "config/setUserClient/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "config/setUserClient/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/init/init/response.json b/priv/tachyon/schema_v1/init/init/response.json deleted file mode 100644 index 30991894d..000000000 --- a/priv/tachyon/schema_v1/init/init/response.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "properties": { - "tachyonVersion": { - "type": "string" - } - }, - "required": [ - "tachyonVersion" - ] - }, - "command": { - "type": "string", - "const": "init/init/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "init/init/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/listener/getSubscriptions/request.json b/priv/tachyon/schema_v1/listener/getSubscriptions/request.json deleted file mode 100644 index aa1310def..000000000 --- a/priv/tachyon/schema_v1/listener/getSubscriptions/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "listener/getSubscriptions/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/listener/getSubscriptions/response.json b/priv/tachyon/schema_v1/listener/getSubscriptions/response.json deleted file mode 100644 index 5d176a77c..000000000 --- a/priv/tachyon/schema_v1/listener/getSubscriptions/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "listener/getSubscriptions/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "listener/getSubscriptions/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/listener/subscribe/request.json b/priv/tachyon/schema_v1/listener/subscribe/request.json deleted file mode 100644 index dfc701f08..000000000 --- a/priv/tachyon/schema_v1/listener/subscribe/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "listener/subscribe/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/listener/subscribe/response.json b/priv/tachyon/schema_v1/listener/subscribe/response.json deleted file mode 100644 index 04b3adfd8..000000000 --- a/priv/tachyon/schema_v1/listener/subscribe/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "listener/subscribe/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "listener/subscribe/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/listener/unsubscribe/request.json b/priv/tachyon/schema_v1/listener/unsubscribe/request.json deleted file mode 100644 index e9a50755a..000000000 --- a/priv/tachyon/schema_v1/listener/unsubscribe/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "listener/unsubscribe/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/listener/unsubscribe/response.json b/priv/tachyon/schema_v1/listener/unsubscribe/response.json deleted file mode 100644 index 1a100c875..000000000 --- a/priv/tachyon/schema_v1/listener/unsubscribe/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "listener/unsubscribe/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "listener/unsubscribe/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/addUserClient/request.json b/priv/tachyon/schema_v1/lobby/addUserClient/request.json deleted file mode 100644 index 6de018bc7..000000000 --- a/priv/tachyon/schema_v1/lobby/addUserClient/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/addUserClient/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/addUserClient/response.json b/priv/tachyon/schema_v1/lobby/addUserClient/response.json deleted file mode 100644 index 32ef924f4..000000000 --- a/priv/tachyon/schema_v1/lobby/addUserClient/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/addUserClient/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/addUserClient/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/botAdded/request.json b/priv/tachyon/schema_v1/lobby/botAdded/request.json deleted file mode 100644 index d31a50ff2..000000000 --- a/priv/tachyon/schema_v1/lobby/botAdded/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/botAdded/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/botAdded/response.json b/priv/tachyon/schema_v1/lobby/botAdded/response.json deleted file mode 100644 index e3ce65cb2..000000000 --- a/priv/tachyon/schema_v1/lobby/botAdded/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/botAdded/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/botAdded/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/botRemoved/request.json b/priv/tachyon/schema_v1/lobby/botRemoved/request.json deleted file mode 100644 index a665aaf3c..000000000 --- a/priv/tachyon/schema_v1/lobby/botRemoved/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/botRemoved/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/botRemoved/response.json b/priv/tachyon/schema_v1/lobby/botRemoved/response.json deleted file mode 100644 index fb943f040..000000000 --- a/priv/tachyon/schema_v1/lobby/botRemoved/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/botRemoved/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/botRemoved/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/botUpdated/request.json b/priv/tachyon/schema_v1/lobby/botUpdated/request.json deleted file mode 100644 index 782187393..000000000 --- a/priv/tachyon/schema_v1/lobby/botUpdated/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/botUpdated/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/botUpdated/response.json b/priv/tachyon/schema_v1/lobby/botUpdated/response.json deleted file mode 100644 index 6c348cdcc..000000000 --- a/priv/tachyon/schema_v1/lobby/botUpdated/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/botUpdated/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/botUpdated/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/closed/request.json b/priv/tachyon/schema_v1/lobby/closed/request.json deleted file mode 100644 index 62da18b8b..000000000 --- a/priv/tachyon/schema_v1/lobby/closed/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/closed/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/closed/response.json b/priv/tachyon/schema_v1/lobby/closed/response.json deleted file mode 100644 index b76365391..000000000 --- a/priv/tachyon/schema_v1/lobby/closed/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/closed/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/closed/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/get/request.json b/priv/tachyon/schema_v1/lobby/get/request.json deleted file mode 100644 index 4fcc78528..000000000 --- a/priv/tachyon/schema_v1/lobby/get/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/get/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/get/response.json b/priv/tachyon/schema_v1/lobby/get/response.json deleted file mode 100644 index 17ec12578..000000000 --- a/priv/tachyon/schema_v1/lobby/get/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/get/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/get/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/getLobbies/request.json b/priv/tachyon/schema_v1/lobby/getLobbies/request.json deleted file mode 100644 index 4b23040d4..000000000 --- a/priv/tachyon/schema_v1/lobby/getLobbies/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/getLobbies/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/getLobbies/response.json b/priv/tachyon/schema_v1/lobby/getLobbies/response.json deleted file mode 100644 index a6a8b75e6..000000000 --- a/priv/tachyon/schema_v1/lobby/getLobbies/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/getLobbies/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/getLobbies/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/join/request.json b/priv/tachyon/schema_v1/lobby/join/request.json deleted file mode 100644 index f7e833392..000000000 --- a/priv/tachyon/schema_v1/lobby/join/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/join/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/join/response.json b/priv/tachyon/schema_v1/lobby/join/response.json deleted file mode 100644 index c39faefb4..000000000 --- a/priv/tachyon/schema_v1/lobby/join/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/join/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/join/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/joined/request.json b/priv/tachyon/schema_v1/lobby/joined/request.json deleted file mode 100644 index aeb52d73e..000000000 --- a/priv/tachyon/schema_v1/lobby/joined/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/joined/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/joined/response.json b/priv/tachyon/schema_v1/lobby/joined/response.json deleted file mode 100644 index 8e0a0bb61..000000000 --- a/priv/tachyon/schema_v1/lobby/joined/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/joined/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/joined/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/leave/request.json b/priv/tachyon/schema_v1/lobby/leave/request.json deleted file mode 100644 index 249a32c95..000000000 --- a/priv/tachyon/schema_v1/lobby/leave/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/leave/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/leave/response.json b/priv/tachyon/schema_v1/lobby/leave/response.json deleted file mode 100644 index e0346d776..000000000 --- a/priv/tachyon/schema_v1/lobby/leave/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/leave/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/leave/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/opened/request.json b/priv/tachyon/schema_v1/lobby/opened/request.json deleted file mode 100644 index 5d92fb70d..000000000 --- a/priv/tachyon/schema_v1/lobby/opened/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/opened/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/opened/response.json b/priv/tachyon/schema_v1/lobby/opened/response.json deleted file mode 100644 index 6aba0c0a3..000000000 --- a/priv/tachyon/schema_v1/lobby/opened/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/opened/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/opened/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/removeUserClient/request.json b/priv/tachyon/schema_v1/lobby/removeUserClient/request.json deleted file mode 100644 index 0307f2936..000000000 --- a/priv/tachyon/schema_v1/lobby/removeUserClient/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/removeUserClient/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/removeUserClient/response.json b/priv/tachyon/schema_v1/lobby/removeUserClient/response.json deleted file mode 100644 index 8d4bed967..000000000 --- a/priv/tachyon/schema_v1/lobby/removeUserClient/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/removeUserClient/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/removeUserClient/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/updateStatus/request.json b/priv/tachyon/schema_v1/lobby/updateStatus/request.json deleted file mode 100644 index aa216403c..000000000 --- a/priv/tachyon/schema_v1/lobby/updateStatus/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/updateStatus/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/updateStatus/response.json b/priv/tachyon/schema_v1/lobby/updateStatus/response.json deleted file mode 100644 index 12d6eb3f3..000000000 --- a/priv/tachyon/schema_v1/lobby/updateStatus/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/updateStatus/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/updateStatus/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/updated/request.json b/priv/tachyon/schema_v1/lobby/updated/request.json deleted file mode 100644 index 20fc35d9c..000000000 --- a/priv/tachyon/schema_v1/lobby/updated/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobby/updated/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobby/updated/response.json b/priv/tachyon/schema_v1/lobby/updated/response.json deleted file mode 100644 index 976c1c286..000000000 --- a/priv/tachyon/schema_v1/lobby/updated/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobby/updated/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobby/updated/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyChat/announce/request.json b/priv/tachyon/schema_v1/lobbyChat/announce/request.json deleted file mode 100644 index 46a354cc4..000000000 --- a/priv/tachyon/schema_v1/lobbyChat/announce/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyChat/announce/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyChat/announce/response.json b/priv/tachyon/schema_v1/lobbyChat/announce/response.json deleted file mode 100644 index 9f037a8eb..000000000 --- a/priv/tachyon/schema_v1/lobbyChat/announce/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyChat/announce/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyChat/announce/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyChat/announced/response.json b/priv/tachyon/schema_v1/lobbyChat/announced/response.json deleted file mode 100644 index f379ae2b6..000000000 --- a/priv/tachyon/schema_v1/lobbyChat/announced/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyChat/announced/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyChat/announced/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyChat/said/response.json b/priv/tachyon/schema_v1/lobbyChat/said/response.json deleted file mode 100644 index f5cd85f40..000000000 --- a/priv/tachyon/schema_v1/lobbyChat/said/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyChat/said/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyChat/said/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyChat/say/request.json b/priv/tachyon/schema_v1/lobbyChat/say/request.json deleted file mode 100644 index 9a1ca770c..000000000 --- a/priv/tachyon/schema_v1/lobbyChat/say/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyChat/say/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyChat/say/response.json b/priv/tachyon/schema_v1/lobbyChat/say/response.json deleted file mode 100644 index 722882e83..000000000 --- a/priv/tachyon/schema_v1/lobbyChat/say/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyChat/say/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyChat/say/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/addBot/request.json b/priv/tachyon/schema_v1/lobbyHost/addBot/request.json deleted file mode 100644 index 993fa3eef..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/addBot/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/addBot/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/addBot/response.json b/priv/tachyon/schema_v1/lobbyHost/addBot/response.json deleted file mode 100644 index 1d79f9c8c..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/addBot/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/addBot/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/addBot/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/close/request.json b/priv/tachyon/schema_v1/lobbyHost/close/request.json deleted file mode 100644 index 46df162e8..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/close/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/close/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/close/response.json b/priv/tachyon/schema_v1/lobbyHost/close/response.json deleted file mode 100644 index 7b0c3eb2a..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/close/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/close/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/close/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/create/request.json b/priv/tachyon/schema_v1/lobbyHost/create/request.json deleted file mode 100644 index f5c06126f..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/create/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/create/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/create/response.json b/priv/tachyon/schema_v1/lobbyHost/create/response.json deleted file mode 100644 index 97e4b93ba..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/create/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/create/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/create/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/endBattle/request.json b/priv/tachyon/schema_v1/lobbyHost/endBattle/request.json deleted file mode 100644 index 16458140c..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/endBattle/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/endBattle/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/endBattle/response.json b/priv/tachyon/schema_v1/lobbyHost/endBattle/response.json deleted file mode 100644 index fbddee961..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/endBattle/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/endBattle/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/endBattle/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/joinRequest/request.json b/priv/tachyon/schema_v1/lobbyHost/joinRequest/request.json deleted file mode 100644 index dd1364d2a..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/joinRequest/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/joinRequest/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/joinRequest/response.json b/priv/tachyon/schema_v1/lobbyHost/joinRequest/response.json deleted file mode 100644 index 4df13c096..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/joinRequest/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/joinRequest/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/joinRequest/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/removeBot/request.json b/priv/tachyon/schema_v1/lobbyHost/removeBot/request.json deleted file mode 100644 index 88ab4354f..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/removeBot/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/removeBot/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/removeBot/response.json b/priv/tachyon/schema_v1/lobbyHost/removeBot/response.json deleted file mode 100644 index 72733a797..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/removeBot/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/removeBot/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/removeBot/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/startBattle/request.json b/priv/tachyon/schema_v1/lobbyHost/startBattle/request.json deleted file mode 100644 index 5c46d4d35..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/startBattle/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/startBattle/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/startBattle/response.json b/priv/tachyon/schema_v1/lobbyHost/startBattle/response.json deleted file mode 100644 index 6184d7b49..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/startBattle/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/startBattle/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/startBattle/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/updateBot/request.json b/priv/tachyon/schema_v1/lobbyHost/updateBot/request.json deleted file mode 100644 index 091fac5b4..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/updateBot/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/updateBot/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/updateBot/response.json b/priv/tachyon/schema_v1/lobbyHost/updateBot/response.json deleted file mode 100644 index 01b5716ea..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/updateBot/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/updateBot/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/updateBot/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/request.json b/priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/request.json deleted file mode 100644 index be151c90b..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "lobbyHost/updatePlayerStatus/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/response.json b/priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/response.json deleted file mode 100644 index 068a8a9d6..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/updatePlayerStatus/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/updatePlayerStatus/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/updatePlayerStatus/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/lobbyHost/updatedStatus/response.json b/priv/tachyon/schema_v1/lobbyHost/updatedStatus/response.json deleted file mode 100644 index c86d806b4..000000000 --- a/priv/tachyon/schema_v1/lobbyHost/updatedStatus/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "lobbyHost/updatedStatus/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "lobbyHost/updatedStatus/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/accept/request.json b/priv/tachyon/schema_v1/matchmaking/accept/request.json deleted file mode 100644 index d44dad3d5..000000000 --- a/priv/tachyon/schema_v1/matchmaking/accept/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/accept/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/accept/response.json b/priv/tachyon/schema_v1/matchmaking/accept/response.json deleted file mode 100644 index c8d476882..000000000 --- a/priv/tachyon/schema_v1/matchmaking/accept/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/accept/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/accept/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/decline/request.json b/priv/tachyon/schema_v1/matchmaking/decline/request.json deleted file mode 100644 index be4efc75b..000000000 --- a/priv/tachyon/schema_v1/matchmaking/decline/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/decline/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/decline/response.json b/priv/tachyon/schema_v1/matchmaking/decline/response.json deleted file mode 100644 index cba802094..000000000 --- a/priv/tachyon/schema_v1/matchmaking/decline/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/decline/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/decline/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/getJoinedQueues/request.json b/priv/tachyon/schema_v1/matchmaking/getJoinedQueues/request.json deleted file mode 100644 index b2df25173..000000000 --- a/priv/tachyon/schema_v1/matchmaking/getJoinedQueues/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/getJoinedQueues/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/getJoinedQueues/response.json b/priv/tachyon/schema_v1/matchmaking/getJoinedQueues/response.json deleted file mode 100644 index 5af7f5f99..000000000 --- a/priv/tachyon/schema_v1/matchmaking/getJoinedQueues/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/getJoinedQueues/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/getJoinedQueues/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/getQueue/request.json b/priv/tachyon/schema_v1/matchmaking/getQueue/request.json deleted file mode 100644 index c4fa7762c..000000000 --- a/priv/tachyon/schema_v1/matchmaking/getQueue/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/getQueue/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/getQueue/response.json b/priv/tachyon/schema_v1/matchmaking/getQueue/response.json deleted file mode 100644 index 49f8ff29b..000000000 --- a/priv/tachyon/schema_v1/matchmaking/getQueue/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/getQueue/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/getQueue/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/getQueues/request.json b/priv/tachyon/schema_v1/matchmaking/getQueues/request.json deleted file mode 100644 index 0e6d32a24..000000000 --- a/priv/tachyon/schema_v1/matchmaking/getQueues/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/getQueues/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/getQueues/response.json b/priv/tachyon/schema_v1/matchmaking/getQueues/response.json deleted file mode 100644 index b21d2343d..000000000 --- a/priv/tachyon/schema_v1/matchmaking/getQueues/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/getQueues/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/getQueues/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/joinQueue/request.json b/priv/tachyon/schema_v1/matchmaking/joinQueue/request.json deleted file mode 100644 index 3f52e7a00..000000000 --- a/priv/tachyon/schema_v1/matchmaking/joinQueue/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/joinQueue/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/joinQueue/response.json b/priv/tachyon/schema_v1/matchmaking/joinQueue/response.json deleted file mode 100644 index 9e71e3b9d..000000000 --- a/priv/tachyon/schema_v1/matchmaking/joinQueue/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/joinQueue/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/joinQueue/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/leaveAllQueues/request.json b/priv/tachyon/schema_v1/matchmaking/leaveAllQueues/request.json deleted file mode 100644 index 1ffe07987..000000000 --- a/priv/tachyon/schema_v1/matchmaking/leaveAllQueues/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/leaveAllQueues/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/leaveAllQueues/response.json b/priv/tachyon/schema_v1/matchmaking/leaveAllQueues/response.json deleted file mode 100644 index 430d10f12..000000000 --- a/priv/tachyon/schema_v1/matchmaking/leaveAllQueues/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/leaveAllQueues/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/leaveAllQueues/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/leaveQueue/request.json b/priv/tachyon/schema_v1/matchmaking/leaveQueue/request.json deleted file mode 100644 index dcdfcfbbf..000000000 --- a/priv/tachyon/schema_v1/matchmaking/leaveQueue/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "matchmaking/leaveQueue/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/leaveQueue/response.json b/priv/tachyon/schema_v1/matchmaking/leaveQueue/response.json deleted file mode 100644 index 9b17129a1..000000000 --- a/priv/tachyon/schema_v1/matchmaking/leaveQueue/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/leaveQueue/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/leaveQueue/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/matchCancelled/response.json b/priv/tachyon/schema_v1/matchmaking/matchCancelled/response.json deleted file mode 100644 index 7858bd3d3..000000000 --- a/priv/tachyon/schema_v1/matchmaking/matchCancelled/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/matchCancelled/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/matchCancelled/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/matchmaking/matchReady/response.json b/priv/tachyon/schema_v1/matchmaking/matchReady/response.json deleted file mode 100644 index 6064e331b..000000000 --- a/priv/tachyon/schema_v1/matchmaking/matchReady/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "matchmaking/matchReady/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "matchmaking/matchReady/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/moderation/getReportingConfigs/request.json b/priv/tachyon/schema_v1/moderation/getReportingConfigs/request.json deleted file mode 100644 index 0b2f26c87..000000000 --- a/priv/tachyon/schema_v1/moderation/getReportingConfigs/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "moderation/getReportingConfigs/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/moderation/getReportingConfigs/response.json b/priv/tachyon/schema_v1/moderation/getReportingConfigs/response.json deleted file mode 100644 index ee460ef1d..000000000 --- a/priv/tachyon/schema_v1/moderation/getReportingConfigs/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "moderation/getReportingConfigs/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "moderation/getReportingConfigs/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/moderation/reportUserClient/request.json b/priv/tachyon/schema_v1/moderation/reportUserClient/request.json deleted file mode 100644 index 6c8e92d64..000000000 --- a/priv/tachyon/schema_v1/moderation/reportUserClient/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "moderation/reportUserClient/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/moderation/reportUserClient/response.json b/priv/tachyon/schema_v1/moderation/reportUserClient/response.json deleted file mode 100644 index 4b05d8537..000000000 --- a/priv/tachyon/schema_v1/moderation/reportUserClient/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "moderation/reportUserClient/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "moderation/reportUserClient/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/news/getNewsItems/request.json b/priv/tachyon/schema_v1/news/getNewsItems/request.json deleted file mode 100644 index 2ab80ecdf..000000000 --- a/priv/tachyon/schema_v1/news/getNewsItems/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "news/getNewsItems/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/news/getNewsItems/response.json b/priv/tachyon/schema_v1/news/getNewsItems/response.json deleted file mode 100644 index 300ed5083..000000000 --- a/priv/tachyon/schema_v1/news/getNewsItems/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "news/getNewsItems/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "news/getNewsItems/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/acceptInvite/request.json b/priv/tachyon/schema_v1/party/acceptInvite/request.json deleted file mode 100644 index 31b77e269..000000000 --- a/priv/tachyon/schema_v1/party/acceptInvite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/acceptInvite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/acceptInvite/response.json b/priv/tachyon/schema_v1/party/acceptInvite/response.json deleted file mode 100644 index f98acb9d6..000000000 --- a/priv/tachyon/schema_v1/party/acceptInvite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/acceptInvite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/acceptInvite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/create/request.json b/priv/tachyon/schema_v1/party/create/request.json deleted file mode 100644 index 9dab626cf..000000000 --- a/priv/tachyon/schema_v1/party/create/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/create/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/create/response.json b/priv/tachyon/schema_v1/party/create/response.json deleted file mode 100644 index d87b5f5bb..000000000 --- a/priv/tachyon/schema_v1/party/create/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/create/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/create/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/declineInvite/request.json b/priv/tachyon/schema_v1/party/declineInvite/request.json deleted file mode 100644 index bbddfc031..000000000 --- a/priv/tachyon/schema_v1/party/declineInvite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/declineInvite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/declineInvite/response.json b/priv/tachyon/schema_v1/party/declineInvite/response.json deleted file mode 100644 index 413db1e85..000000000 --- a/priv/tachyon/schema_v1/party/declineInvite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/declineInvite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/declineInvite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/getParty/request.json b/priv/tachyon/schema_v1/party/getParty/request.json deleted file mode 100644 index b95baf922..000000000 --- a/priv/tachyon/schema_v1/party/getParty/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/getParty/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/getParty/response.json b/priv/tachyon/schema_v1/party/getParty/response.json deleted file mode 100644 index c8a354f41..000000000 --- a/priv/tachyon/schema_v1/party/getParty/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/getParty/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/getParty/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/invite/request.json b/priv/tachyon/schema_v1/party/invite/request.json deleted file mode 100644 index bacc2b44f..000000000 --- a/priv/tachyon/schema_v1/party/invite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/invite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/invite/response.json b/priv/tachyon/schema_v1/party/invite/response.json deleted file mode 100644 index dd49c7387..000000000 --- a/priv/tachyon/schema_v1/party/invite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/invite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/invite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/kick/request.json b/priv/tachyon/schema_v1/party/kick/request.json deleted file mode 100644 index 2d8db1401..000000000 --- a/priv/tachyon/schema_v1/party/kick/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/kick/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/kick/response.json b/priv/tachyon/schema_v1/party/kick/response.json deleted file mode 100644 index 992357f4a..000000000 --- a/priv/tachyon/schema_v1/party/kick/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/kick/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/kick/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/rescindInvite/request.json b/priv/tachyon/schema_v1/party/rescindInvite/request.json deleted file mode 100644 index 8079da9eb..000000000 --- a/priv/tachyon/schema_v1/party/rescindInvite/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/rescindInvite/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/rescindInvite/response.json b/priv/tachyon/schema_v1/party/rescindInvite/response.json deleted file mode 100644 index 87da376e9..000000000 --- a/priv/tachyon/schema_v1/party/rescindInvite/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/rescindInvite/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/rescindInvite/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/seeMessage/response.json b/priv/tachyon/schema_v1/party/seeMessage/response.json deleted file mode 100644 index 1d96ecb9c..000000000 --- a/priv/tachyon/schema_v1/party/seeMessage/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/seeMessage/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/seeMessage/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/sendMessage/request.json b/priv/tachyon/schema_v1/party/sendMessage/request.json deleted file mode 100644 index 64b10b6a8..000000000 --- a/priv/tachyon/schema_v1/party/sendMessage/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "party/sendMessage/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/sendMessage/response.json b/priv/tachyon/schema_v1/party/sendMessage/response.json deleted file mode 100644 index 72210aa48..000000000 --- a/priv/tachyon/schema_v1/party/sendMessage/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/sendMessage/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/sendMessage/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/party/updated/response.json b/priv/tachyon/schema_v1/party/updated/response.json deleted file mode 100644 index 514a5c86a..000000000 --- a/priv/tachyon/schema_v1/party/updated/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "party/updated/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "party/updated/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/system/error/response.json b/priv/tachyon/schema_v1/system/error/response.json deleted file mode 100644 index f8f826410..000000000 --- a/priv/tachyon/schema_v1/system/error/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "system/error/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "system/error/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/system/serverEvent/response.json b/priv/tachyon/schema_v1/system/serverEvent/response.json deleted file mode 100644 index da8e250a7..000000000 --- a/priv/tachyon/schema_v1/system/serverEvent/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "system/serverEvent/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "system/serverEvent/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/telemetry/event/request.json b/priv/tachyon/schema_v1/telemetry/event/request.json deleted file mode 100644 index 7f5582b11..000000000 --- a/priv/tachyon/schema_v1/telemetry/event/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "telemetry/event/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/telemetry/event/response.json b/priv/tachyon/schema_v1/telemetry/event/response.json deleted file mode 100644 index 34e2cbee6..000000000 --- a/priv/tachyon/schema_v1/telemetry/event/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "telemetry/event/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "telemetry/event/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/telemetry/property/request.json b/priv/tachyon/schema_v1/telemetry/property/request.json deleted file mode 100644 index 59c1fddf1..000000000 --- a/priv/tachyon/schema_v1/telemetry/property/request.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "object", - "properties": { - "command": { - "type": "string", - "const": "telemetry/property/request" - } - }, - "required": [ - "command" - ] -} \ No newline at end of file diff --git a/priv/tachyon/schema_v1/telemetry/property/response.json b/priv/tachyon/schema_v1/telemetry/property/response.json deleted file mode 100644 index 6c00c36ae..000000000 --- a/priv/tachyon/schema_v1/telemetry/property/response.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "anyOf": [ - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "success" - }, - "data": { - "type": "object", - "additionalProperties": { - - } - }, - "command": { - "type": "string", - "const": "telemetry/property/response" - } - }, - "required": [ - "command", - "data", - "status" - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "string", - "const": "failed" - }, - "reason": { - "type": "string", - "const": "internal_error" - }, - "command": { - "type": "string", - "const": "telemetry/property/response" - } - }, - "required": [ - "command", - "reason", - "status" - ] - } - ] -} \ No newline at end of file diff --git a/test/support/teiserver_test_lib.ex b/test/support/teiserver_test_lib.ex index 92d158b6e..3af48de02 100644 --- a/test/support/teiserver_test_lib.ex +++ b/test/support/teiserver_test_lib.ex @@ -2,7 +2,6 @@ defmodule Teiserver.TeiserverTestLib do @moduledoc false alias Teiserver.{Client, CacheUser, Account} alias Teiserver.Account.AccoladeLib - alias Teiserver.Protocols.TachyonLib alias Teiserver.Coordinator.CoordinatorServer alias Teiserver.Data.Types, as: T @host '127.0.0.1' @@ -26,17 +25,6 @@ defmodule Teiserver.TeiserverTestLib do %{socket: socket} end - @spec tachyon_tls_setup :: %{socket: port()} - def tachyon_tls_setup() do - {:ok, socket} = - :ssl.connect(@host, 9202, - active: false, - verify: :verify_none - ) - - %{socket: socket} - end - @spec new_user_name :: String.t() def new_user_name() do "test_user_#{:rand.uniform(99_999_999) + 1_000_000}" @@ -125,37 +113,6 @@ defmodule Teiserver.TeiserverTestLib do %{socket: socket, user: user, pid: pid} end - @spec tachyon_auth_setup(nil | map()) :: %{socket: port(), user: map(), pid: pid()} - def tachyon_auth_setup(user \\ nil) do - user = if user, do: user, else: new_user() - token = CacheUser.create_token(user) - - %{socket: socket} = tachyon_tls_setup() - - # Now do our login - data = %{ - cmd: "c.auth.login", - token: token, - lobby_name: "ex_test", - lobby_version: "1a", - lobby_hash: "t1 t2" - } - - _tachyon_send(socket, data) - reply = _tachyon_recv(socket) - - case reply do - [%{"result" => "unverified"} | _] -> - raise "You are creating a user without verifying in" - - _ -> - :ok - end - - pid = Client.get_client_by_id(user.id).tcp_pid - %{socket: socket, user: user, pid: pid} - end - def _send_lines(state = %{mock: true}, msg) do state.protocol_in.data_in(msg, state) end @@ -244,56 +201,6 @@ defmodule Teiserver.TeiserverTestLib do end end - def _tachyon_send(socket, data) do - msg = TachyonLib.encode(data) - _send_raw(socket, msg <> "\n") - end - - def _tachyon_recv(socket) do - case _recv_raw(socket) do - :timeout -> - :timeout - - :closed -> - :closed - - resp -> - resp - |> String.split("\n") - |> Enum.map(fn line -> - case TachyonLib.decode(line) do - {:ok, msg} -> msg - error -> error - end - end) - |> Enum.filter(fn r -> r != nil end) - end - end - - def _tachyon_recv_until(socket), do: _tachyon_recv_until(socket, []) - - def _tachyon_recv_until(socket = {:sslsocket, _, _}, acc) do - case :ssl.recv(socket, 0, 500) do - {:ok, reply} -> - resp = - reply - |> to_string - |> String.split("\n") - |> Enum.map(fn line -> - case TachyonLib.decode(line) do - {:ok, msg} -> msg - error -> error - end - end) - |> Enum.filter(fn r -> r != nil end) - - _tachyon_recv_until(socket, acc ++ resp) - - {:error, :timeout} -> - acc - end - end - def mock_socket() do %{ mock: true, diff --git a/test/teiserver/account/accolade_bot_test.exs b/test/teiserver/account/accolade_bot_test.exs deleted file mode 100644 index 02fad3411..000000000 --- a/test/teiserver/account/accolade_bot_test.exs +++ /dev/null @@ -1,329 +0,0 @@ -defmodule Teiserver.Account.AccoladeBotTest do - @moduledoc false - use Teiserver.ServerCase, async: false - # alias Phoenix.PubSub - - alias Teiserver.{Battle, Account, CacheUser} - alias Teiserver.Account.AccoladeLib - require Logger - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_recv: 1, _tachyon_send: 2] - - @moduletag :needs_attention - - setup do - AccoladeLib.start_accolade_server() - - # First number is team, second number is member of the team - %{socket: _hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket11, user: player11} = tachyon_auth_setup() - %{socket: psocket12, user: player12} = tachyon_auth_setup() - %{socket: psocket21, user: player21} = tachyon_auth_setup() - %{socket: psocket22, user: player22} = tachyon_auth_setup() - - {:ok, match} = - Battle.create_match(%{ - uuid: UUID.uuid1(), - map: "red desert", - data: %{}, - tags: %{}, - team_count: 2, - team_size: 2, - passworded: false, - game_type: "Small Team", - founder_id: host.id, - founder_name: host.name, - server_uuid: "123", - bots: %{}, - started: Timex.now() |> Timex.shift(minutes: -30), - finished: Timex.now() |> Timex.shift(seconds: -30) - }) - - data = %{match_id: match.id, user_id: nil, team_id: nil} - - Battle.create_match_membership(%{data | user_id: player11.id, team_id: 1}) - Battle.create_match_membership(%{data | user_id: player12.id, team_id: 1}) - Battle.create_match_membership(%{data | user_id: player21.id, team_id: 2}) - Battle.create_match_membership(%{data | user_id: player22.id, team_id: 2}) - - badge_type1 = - AccoladeLib.get_badge_types() - |> Enum.filter(fn {i, _} -> i == 1 end) - |> hd - |> elem(1) - - {:ok, - match: match, - badge_type1: badge_type1, - player11: player11, - player12: player12, - psocket11: psocket11, - psocket12: psocket12, - psocket21: psocket21, - psocket22: psocket22} - end - - test "short battle", %{match: match, player11: player11, psocket11: psocket11} do - Battle.update_match(match, %{ - started: Timex.now() |> Timex.shift(seconds: -200), - finished: Timex.now() |> Timex.shift(seconds: -30) - }) - - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - - AccoladeLib.cast_accolade_bot(%{ - channel: "global_match_updates", - event: :match_completed, - match_id: match.id - }) - - :timer.sleep(100) - - # Now, player11 should have zero messages because it was a short game - :timeout = _tachyon_recv(psocket11) - end - - test "basic post match stuff", %{ - match: match, - player11: player11, - player12: player12, - psocket11: psocket11, - badge_type1: badge_type1 - } do - # player11 should have no accolades given - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - - AccoladeLib.cast_accolade_bot(%{ - channel: "global_match_updates", - event: :match_completed, - match_id: match.id - }) - - :timer.sleep(100) - - # Now, player11 should have a set of messages - [result] = _tachyon_recv(psocket11) - - assert result["cmd"] == "s.communication.received_direct_message" - assert result["sender_id"] == AccoladeLib.get_accolade_bot_userid() - - assert match?( - [ - "-------------------------------------------------", - _, - "Which of the following accolades do you feel they most deserve (if any)?", - "N - No accolade for this player at all", - "0 - No accolade this time, ask again later", - "1 - Badge A, Description for the first badge", - "2 - Badge B, Description for the second badge", - "3 - Badge C, Description for the third badge", - ".", - "Reply to this message with the number corresponding to the Accolade you feel is most appropriate for this player for this match." - ], - result["message"] |> String.split("\n") - ) - - assert Enum.at(result["message"] |> String.split("\n"), 1) == - "You have an opportunity to leave feedback on one of the players in your last game. We have selected #{player12.name}" - - # Now send the response, pick the first accolade - _tachyon_send(psocket11, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => AccoladeLib.get_accolade_bot_userid(), - "message" => "1" - }) - - :timer.sleep(400) - - # We expect success regarding sending the message - [result] = _tachyon_recv(psocket11) - assert result == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - # And a response from the Accolade chat bot - [result] = _tachyon_recv(psocket11) - - assert result == %{ - "cmd" => "s.communication.received_direct_message", - "message" => "Thank you for your feedback, this Accolade will be bestowed.", - "sender_id" => AccoladeLib.get_accolade_bot_userid() - } - - # For some reason this might fail as part of a larger test but not a smaller - [accolade_given] = Account.list_accolades(search: [giver_id: player11.id]) - assert accolade_given.giver_id == player11.id - assert accolade_given.recipient_id == player12.id - assert accolade_given.badge_type_id == badge_type1.id - - # Now send something again - _tachyon_send(psocket11, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => AccoladeLib.get_accolade_bot_userid(), - "message" => "1" - }) - - :timer.sleep(400) - - # Should be no differences in the results - [accolade_given] = Account.list_accolades(search: [giver_id: player11.id]) - assert accolade_given.giver_id == player11.id - assert accolade_given.recipient_id == player12.id - assert accolade_given.badge_type_id == badge_type1.id - end - - test "send N", %{match: match, player11: player11, player12: player12, psocket11: psocket11} do - # player11 should have no accolades given - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - - AccoladeLib.cast_accolade_bot(%{ - channel: "global_match_updates", - event: :match_completed, - match_id: match.id - }) - - :timer.sleep(100) - - # Now, player11 should have a set of messages - [result] = _tachyon_recv(psocket11) - - assert result["cmd"] == "s.communication.received_direct_message" - assert result["sender_id"] == AccoladeLib.get_accolade_bot_userid() - - assert match?( - [ - "-------------------------------------------------", - _, - "Which of the following accolades do you feel they most deserve (if any)?", - "N - No accolade for this player at all", - "0 - No accolade this time, ask again later", - "1 - Badge A, Description for the first badge", - "2 - Badge B, Description for the second badge", - "3 - Badge C, Description for the third badge", - ".", - "Reply to this message with the number corresponding to the Accolade you feel is most appropriate for this player for this match." - ], - result["message"] |> String.split("\n") - ) - - assert Enum.at(result["message"] |> String.split("\n"), 1) == - "You have an opportunity to leave feedback on one of the players in your last game. We have selected #{player12.name}" - - # Now send the response, pick the first accolade - _tachyon_send(psocket11, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => AccoladeLib.get_accolade_bot_userid(), - "message" => "N" - }) - - :timer.sleep(200) - - # If this bit breaks it's because the "null" accolade wasn't inserted because of a foreign key constraint - # that doesn't exist and can't be reliably replicated - [accolade_given] = Account.list_accolades(search: [giver_id: player11.id]) - assert accolade_given.giver_id == player11.id - assert accolade_given.recipient_id == player12.id - assert accolade_given.badge_type_id == nil - end - - test "Send 0", %{match: match, player11: player11, player12: player12, psocket11: psocket11} do - # player11 should have no accolades given - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - - AccoladeLib.cast_accolade_bot(%{ - channel: "global_match_updates", - event: :match_completed, - match_id: match.id - }) - - :timer.sleep(100) - - # Now, player11 should have a set of messages - [result] = _tachyon_recv(psocket11) - - assert result["cmd"] == "s.communication.received_direct_message" - assert result["sender_id"] == AccoladeLib.get_accolade_bot_userid() - - assert match?( - [ - "-------------------------------------------------", - _, - "Which of the following accolades do you feel they most deserve (if any)?", - "N - No accolade for this player at all", - "0 - No accolade this time, ask again later", - "1 - Badge A, Description for the first badge", - "2 - Badge B, Description for the second badge", - "3 - Badge C, Description for the third badge", - ".", - "Reply to this message with the number corresponding to the Accolade you feel is most appropriate for this player for this match." - ], - result["message"] |> String.split("\n") - ) - - assert Enum.at(result["message"] |> String.split("\n"), 1) == - "You have an opportunity to leave feedback on one of the players in your last game. We have selected #{player12.name}" - - # Now send the response, pick the first accolade - _tachyon_send(psocket11, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => AccoladeLib.get_accolade_bot_userid(), - "message" => "0" - }) - - :timer.sleep(200) - - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - end - - test "not allowed - miss_count", %{ - match: match, - player11: player11, - player12: player12, - psocket11: psocket11 - } do - # player11 should have no accolades given - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - - # restrict player12 from getting accolades - Account.update_user_stat(player12.id, %{ - "accolade_miss_count" => 500 - }) - - :timer.sleep(100) - - AccoladeLib.cast_accolade_bot(%{ - channel: "global_match_updates", - event: :match_completed, - match_id: match.id - }) - - :timer.sleep(100) - - # Now, player11 should not have a message - assert _tachyon_recv(psocket11) == :timeout - end - - test "not allowed - restricted", %{ - match: match, - player11: player11, - player12: player12, - psocket11: psocket11 - } do - # player11 should have no accolades given - assert Account.list_accolades(search: [giver_id: player11.id]) == [] - - # restrict player11 from getting accolades - CacheUser.restrict_user(player12.id, "Accolades") - :timer.sleep(100) - - AccoladeLib.cast_accolade_bot(%{ - channel: "global_match_updates", - event: :match_completed, - match_id: match.id - }) - - :timer.sleep(100) - - # Now, player11 should not have a message - assert _tachyon_recv(psocket11) == :timeout - end -end diff --git a/test/teiserver/battle/lobby_cache_test.exs b/test/teiserver/battle/lobby_cache_test.exs deleted file mode 100644 index e22863894..000000000 --- a/test/teiserver/battle/lobby_cache_test.exs +++ /dev/null @@ -1,49 +0,0 @@ -defmodule Teiserver.Lobby.LobbyLibTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{Account, Lobby} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - type: "normal", - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - }, - password: nil, - module: to_string(__MODULE__) - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - test "add_user_to_battle", %{lobby_id: lobby_id, player: player} do - p_client = Account.get_client_by_id(player.id) - assert p_client.lobby_id == nil - - Lobby.force_add_user_to_lobby(player.id, lobby_id) - p_client = Account.get_client_by_id(player.id) - assert p_client.lobby_id == lobby_id - end -end diff --git a/test/teiserver/coordinator/automod_test.exs b/test/teiserver/coordinator/automod_test.exs deleted file mode 100644 index a3fb9f196..000000000 --- a/test/teiserver/coordinator/automod_test.exs +++ /dev/null @@ -1,258 +0,0 @@ -defmodule Teiserver.Coordinator.AutomodTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{Config} - alias Teiserver.{Account, CacheUser, Client, Moderation, Logging} - alias Teiserver.Coordinator.{CoordinatorServer, AutomodServer} - alias Teiserver.Account.CalculateSmurfKeyTask - - import Teiserver.TeiserverTestLib, - only: [new_user: 0, tachyon_auth_setup: 1, _tachyon_send: 2] - - @moduletag :needs_attention - - setup do - account = CoordinatorServer.get_coordinator_account() - Teiserver.cache_put(:application_metadata_cache, "teiserver_coordinator_userid", account.id) - - Teiserver.Coordinator.AutomodServer.start_automod_server() - - Config.update_site_config("teiserver.Automod action delay", 0) - banned_user = new_user() - {:ok, banned_user: banned_user} - end - - test "hw_ban", %{banned_user: banned_user} do - {:ok, _ban} = - Moderation.create_ban(%{ - enabled: true, - key_values: ["uOGXziwWC1mCePGsh0tTQg==", "some_other_value"], - added_by_id: banned_user.id, - source_id: banned_user.id, - reason: "hw-ban" - }) - - # We have to sleep so the user is created after the ban - :timer.sleep(1000) - - good_user = new_user() - - good_stats = %{ - "hardware:cpuinfo" => "123", - "hardware:gpuinfo" => "123", - "hardware:osinfo" => "123", - "hardware:raminfo" => "123", - "hardware:displaymax" => "123" - } - - hw1 = CalculateSmurfKeyTask.calculate_hw1_fingerprint(good_stats) - hw2 = CalculateSmurfKeyTask.calculate_hw2_fingerprint(good_stats) - hw3 = CalculateSmurfKeyTask.calculate_hw2_fingerprint(good_stats) - Account.create_smurf_key(good_user.id, "hw1", hw1) - Account.create_smurf_key(good_user.id, "hw2", hw2) - Account.create_smurf_key(good_user.id, "hw3", hw3) - - :timer.sleep(100) - - bad_user = new_user() - - bad_stats = %{ - "hardware:cpuinfo" => "xyz", - "hardware:gpuinfo" => "xyz", - "hardware:osinfo" => "xyz", - "hardware:raminfo" => "xyz", - "hardware:displaymax" => "xyz" - } - - hw1 = CalculateSmurfKeyTask.calculate_hw1_fingerprint(bad_stats) - hw2 = CalculateSmurfKeyTask.calculate_hw2_fingerprint(bad_stats) - hw3 = CalculateSmurfKeyTask.calculate_hw3_fingerprint(bad_stats) - Account.create_smurf_key(bad_user.id, "hw1", hw1) - Account.create_smurf_key(bad_user.id, "hw2", hw2) - Account.create_smurf_key(bad_user.id, "hw3", hw3) - - result = AutomodServer.check_user(good_user.id) - assert result == "No action" - - result = AutomodServer.check_user(bad_user.id) - assert result == "Banned user" - end - - test "chobby_hash_ban", %{banned_user: banned_user} do - {:ok, _ban} = - Moderation.create_ban(%{ - enabled: true, - key_values: ["123456789 abcdefghij"], - added_by_id: banned_user.id, - source_id: banned_user.id, - reason: "hw-ban" - }) - - # We have to sleep so the user is created after the ban - :timer.sleep(1000) - - good_user1 = new_user() - Account.create_smurf_key(good_user1.id, "chobby_hash", "123456789") - - good_user2 = new_user() - Account.create_smurf_key(good_user2.id, "chobby_hash", "abcdefghij") - - good_user3 = new_user() - Account.create_smurf_key(good_user3.id, "chobby_hash", "123456789 abcdefghijj") - - bad_user = new_user() - Account.create_smurf_key(bad_user.id, "chobby_hash", "123456789 abcdefghij") - - result = AutomodServer.check_user(good_user1.id) - assert result == "No action" - - result = AutomodServer.check_user(good_user2.id) - assert result == "No action" - - result = AutomodServer.check_user(good_user3.id) - assert result == "No action" - - result = AutomodServer.check_user(bad_user.id) - assert result == "Banned user" - end - - test "ban added after user", %{banned_user: banned_user} do - bad_user1 = new_user() - Account.create_smurf_key(bad_user1.id, "chobby_hash", "123456789") - :timer.sleep(1_000) - - {:ok, _ban} = - Moderation.create_ban(%{ - enabled: true, - key_values: ["123456789"], - added_by_id: banned_user.id, - source_id: banned_user.id, - reason: "hw-ban" - }) - - # We have to sleep so the user is created after the ban - :timer.sleep(1000) - - bad_user2 = new_user() - Account.create_smurf_key(bad_user2.id, "chobby_hash", "123456789") - - # User1 was created before the permaban, they are not banned - result = AutomodServer.check_user(bad_user1.id) - assert result == "No action" - - # User2 was created after it, they get banned - result = AutomodServer.check_user(bad_user2.id) - assert result == "Banned user" - end - - @tag :needs_attention - test "delayed data", %{banned_user: banned_user} do - {:ok, _ban} = - Moderation.create_ban(%{ - enabled: true, - key_values: ["uOGXziwWC1mCePGsh0tTQg=="], - added_by_id: banned_user.id, - source_id: banned_user.id, - reason: "hw-ban" - }) - - # We have to sleep so the user is created after the ban - :timer.sleep(1000) - - Teiserver.Battle.MatchMonitorServer.do_start() - - standard_user = new_user() - %{socket: standard_socket} = tachyon_auth_setup(standard_user) - - bot_user = new_user() - Account.update_cache_user(bot_user.id, %{roles: ["Bot", "Verified"]}) - %{socket: bot_socket} = tachyon_auth_setup(bot_user) - assert CacheUser.is_bot?(bot_user.id) - - monitor_user = Account.get_user_by_name("AutohostMonitor") - - delayed_user = new_user() - %{socket: _delayed_socket} = tachyon_auth_setup(delayed_user) - - result = AutomodServer.check_user(delayed_user.id) - assert result == "No action" - stats = Account.get_user_stat_data(delayed_user.id) - - assert match?( - %{ - "country" => "??", - "bot" => false, - "last_ip" => "127.0.0.1", - "lobby_hash" => "t1 t2", - "rank" => 0 - }, - stats - ) - - refute Map.has_key?(stats, "hardware:cpuinfo") - - # Now we send some data from the standard user - encoded = - %{ - "username" => delayed_user.name, - "CPU" => "xyz", - "GPU" => "xyz", - "OS" => "xyz", - "RAM" => "xyz" - } - |> Jason.encode!() - |> :zlib.compress() - |> Base.url_encode64() - - _tachyon_send(standard_socket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => monitor_user.id, - "message" => "user_info " <> encoded - }) - - :timer.sleep(200) - assert Enum.count(Account.list_smurf_keys(search: [user_id: delayed_user.id])) == 1 - - # Should be no update - stats = Account.get_user_stat_data(delayed_user.id) - refute Map.has_key?(stats, "hardware:cpuinfo") - - # Should still be connected - refute Client.get_client_by_id(delayed_user.id) == nil - - # Now send from a bot user - _tachyon_send(bot_socket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => monitor_user.id, - "message" => "user_info " <> encoded - }) - - :timer.sleep(200) - - # Should now have smurf keys - assert Enum.count(Account.list_smurf_keys(search: [user_id: delayed_user.id])) == 4 - - # Should be a key now! - stats = Account.get_user_stat_data(delayed_user.id) - assert Map.has_key?(stats, "hardware:cpuinfo") - - # Should also have an automod report against them - [log] = - Logging.list_audit_logs( - search: [ - actions: [ - "Moderation:Ban enacted" - ], - details_equal: {"target_user_id", delayed_user.id |> to_string} - ], - order_by: "Newest first" - ) - - ban_id = log.details["ban_id"] - - # Ensure it exists - Moderation.get_ban!(ban_id) - - # And disconnected - assert Client.get_client_by_id(delayed_user.id) == nil - end -end diff --git a/test/teiserver/coordinator/balance_server_test.exs b/test/teiserver/coordinator/balance_server_test.exs deleted file mode 100644 index c417bdfee..000000000 --- a/test/teiserver/coordinator/balance_server_test.exs +++ /dev/null @@ -1,651 +0,0 @@ -defmodule Teiserver.Coordinator.BalanceServerTest do - @moduledoc false - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.Game.MatchRatingLib - alias Teiserver.{Account, Lobby, Battle, CacheUser, Client, Coordinator} - alias Teiserver.Coordinator.ConsulServer - - import Teiserver.TeiserverTestLib, - only: [ - tachyon_auth_setup: 0, - _tachyon_send: 2, - _tachyon_recv: 1, - _tachyon_recv_until: 1, - tachyon_auth_setup: 1, - new_user: 1 - ] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - CacheUser.update_user(%{host | roles: ["Moderator"]}) - ClientLib.refresh_client(host.id) - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 16 - } - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.add_user_to_battle(player.id, lobby_id, "script_password") - player_client = Account.get_client_by_id(player.id) - Client.update(%{player_client | player: true}, :client_updated_battlestatus) - - # Add user message - _tachyon_recv_until(hsocket) - - # Battlestatus message - _tachyon_recv_until(hsocket) - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - defp make_rating(userid, rating_type_id, rating_value) do - {:ok, _} = - Account.create_rating(%{ - user_id: userid, - rating_type_id: rating_type_id, - rating_value: rating_value, - skill: rating_value, - uncertainty: 0, - leaderboard_rating: rating_value, - last_updated: Timex.now() - }) - end - - test "server balance - simple", %{ - lobby_id: lobby_id, - host: _host, - psocket: _psocket, - player: player - } do - # We don't want to use the player we start with, we want to number our players specifically - Lobby.remove_user_from_any_lobby(player.id) - - %{user: u1} = ps1 = new_user("Team_Arbiter") |> tachyon_auth_setup() - %{user: u2} = ps2 = new_user("Team_Brute") |> tachyon_auth_setup() - %{user: u3} = ps3 = new_user("Team_Calamity") |> tachyon_auth_setup() - %{user: u4} = ps4 = new_user("Team_Destroyer") |> tachyon_auth_setup() - %{user: u5} = ps5 = new_user("Team_Eagle") |> tachyon_auth_setup() - %{user: u6} = ps6 = new_user("Team_Fury") |> tachyon_auth_setup() - %{user: u7} = ps7 = new_user("Team_Garpike") |> tachyon_auth_setup() - %{user: u8} = ps8 = new_user("Team_Hound") |> tachyon_auth_setup() - - # Sleep to allow the users to be correctly added, otherwise we get PK errors we'd not - # get in prod - :timer.sleep(1000) - - rating_type_id = MatchRatingLib.rating_type_name_lookup()["Team"] - - [ps1, ps2, ps3, ps4, ps5, ps6, ps7, ps8] - |> Enum.each(fn %{user: user, socket: socket} -> - Lobby.force_add_user_to_lobby(user.id, lobby_id) - # Need the sleep to ensure they all get added to the battle - :timer.sleep(50) - _tachyon_send(socket, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - end) - - # Create some ratings - # higher numbered players have higher ratings - make_rating(u1.id, rating_type_id, 20) - make_rating(u2.id, rating_type_id, 25) - make_rating(u3.id, rating_type_id, 30) - make_rating(u4.id, rating_type_id, 35) - make_rating(u5.id, rating_type_id, 36) - make_rating(u6.id, rating_type_id, 38) - make_rating(u7.id, rating_type_id, 47) - make_rating(u8.id, rating_type_id, 50) - - # Wait for everybody to get added to the room - :timer.sleep(500) - - consul_state = Coordinator.call_consul(lobby_id, :get_all) - max_player_count = ConsulServer.get_max_player_count(consul_state) - assert max_player_count >= 8 - - assert Battle.list_lobby_players(lobby_id) |> Enum.count() == 8 - - opts = [ - shuffle_first_pick: false, - fuzz_multiplier: 0 - ] - - team_count = 2 - - balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert balance_result.team_players[1] == [u8.id, u5.id, u3.id, u2.id] - assert balance_result.team_players[2] == [u7.id, u6.id, u4.id, u1.id] - assert balance_result.deviation == 1 - assert balance_result.ratings == %{1 => 141.0, 2 => 140.0} - assert Battle.get_lobby_balance_mode(lobby_id) == :solo - - # It caches so calling it with the same settings should result in the same value - assert Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) == balance_result - - # Now if we do it again but with groups allowed it should be the same results but - # with grouped set to true - # we set the opts here rather than using the defaults because if the defaults change it will - # break the test - opts = [ - shuffle_first_pick: false, - allow_groups: true, - mean_diff_max: 15, - stddev_diff_max: 10, - rating_lower_boundary: 5, - rating_upper_boundary: 5, - max_deviation: 10, - fuzz_multiplier: 0 - ] - - grouped_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert grouped_balance_result.team_players[1] == [u8.id, u5.id, u3.id, u2.id] - assert grouped_balance_result.team_players[2] == [u7.id, u6.id, u4.id, u1.id] - assert grouped_balance_result.deviation == 1 - assert grouped_balance_result.ratings == %{1 => 141.0, 2 => 140.0} - assert Battle.get_lobby_balance_mode(lobby_id) == :grouped - assert grouped_balance_result.hash != balance_result.hash - - # Party time, we start with the two highest rated players being put on the same team - high_party = Account.create_party(u8.id) - Account.move_client_to_party(u7.id, high_party.id) - - # Sleep so we don't get a cached list of players when calculating the balance - :timer.sleep(520) - - party_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - # First things first, it should be a different hash - refute party_balance_result.hash == balance_result.hash - - assert party_balance_result.team_players[1] == [u7.id, u8.id, u3.id, u1.id] - assert party_balance_result.team_players[2] == [u6.id, u4.id, u5.id, u2.id] - assert party_balance_result.ratings == %{1 => 147.0, 2 => 134.0} - assert party_balance_result.deviation == 9 - assert party_balance_result.balance_mode == :grouped - assert Battle.get_lobby_balance_mode(lobby_id) == :grouped - - assert party_balance_result.logs == [ - "Group matching", - "> Grouped: Team_Garpike, Team_Hound", - "--- Rating sum: 97.0", - "--- Rating Mean: 48.5", - "--- Rating Stddev: 1.5", - "> Grouped: Team_Fury, Team_Destroyer", - "--- Rating sum: 73.0", - "--- Rating Mean: 36.5", - "--- Rating Stddev: 1.5", - "End of pairing", - "Group picked Team_Garpike, Team_Hound for team 1, adding 97.0 points for new total of 97.0", - "Group picked Team_Fury, Team_Destroyer for team 2, adding 73.0 points for new total of 73.0", - "Picked Team_Eagle for team 2, adding 36.0 points for new total of 109.0", - "Picked Team_Calamity for team 1, adding 30.0 points for new total of 127.0", - "Picked Team_Brute for team 2, adding 25.0 points for new total of 134.0", - "Picked Team_Arbiter for team 1, adding 20.0 points for new total of 147.0" - ] - - # Now make an unfair party - Account.move_client_to_party(u6.id, high_party.id) - Account.move_client_to_party(u5.id, high_party.id) - - :timer.sleep(520) - - opts = [ - shuffle_first_pick: false, - allow_groups: true, - mean_diff_max: 20, - stddev_diff_max: 10, - rating_lower_boundary: 5, - rating_upper_boundary: 5, - max_deviation: 10, - fuzz_multiplier: 0 - ] - - party_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - # First things first, it should be a different hash - refute party_balance_result.hash == balance_result.hash - - # Results should be the same as the first part of the test but with mode set to solo - assert Battle.get_lobby_balance_mode(lobby_id) == :solo - assert party_balance_result.balance_mode == :solo - assert party_balance_result.team_players[1] == [u8.id, u5.id, u3.id, u2.id] - assert party_balance_result.team_players[2] == [u7.id, u6.id, u4.id, u1.id] - assert party_balance_result.ratings == %{1 => 141.0, 2 => 140.0} - assert party_balance_result.deviation == 1 - - assert party_balance_result.logs == [ - "Tried grouped mode, got a deviation of 36 and reverted to solo mode", - "Picked Team_Hound for team 1, adding 50.0 points for new total of 50.0", - "Picked Team_Garpike for team 2, adding 47.0 points for new total of 47.0", - "Picked Team_Fury for team 2, adding 38.0 points for new total of 85.0", - "Picked Team_Eagle for team 1, adding 36.0 points for new total of 86.0", - "Picked Team_Destroyer for team 2, adding 35.0 points for new total of 120.0", - "Picked Team_Calamity for team 1, adding 30.0 points for new total of 116.0", - "Picked Team_Brute for team 1, adding 25.0 points for new total of 141.0", - "Picked Team_Arbiter for team 2, adding 20.0 points for new total of 140.0" - ] - - # Now 8 more users to test some 8v8 stuff - %{user: u9} = ps9 = new_user("Team_Incisor") |> tachyon_auth_setup() - %{user: u10} = ps10 = new_user("Team_Janus") |> tachyon_auth_setup() - %{user: u11} = ps11 = new_user("Team_Karganeth") |> tachyon_auth_setup() - %{user: u12} = ps12 = new_user("Team_Lancer") |> tachyon_auth_setup() - %{user: u13} = ps13 = new_user("Team_Mace") |> tachyon_auth_setup() - %{user: u14} = ps14 = new_user("Team_Nimrod") |> tachyon_auth_setup() - %{user: u15} = ps15 = new_user("Team_Obscurer") |> tachyon_auth_setup() - %{user: u16} = ps16 = new_user("Team_Pawn") |> tachyon_auth_setup() - - # Sleep to allow the users to be correctly added, otherwise we get PK errors we'd not - # get in prod - :timer.sleep(1000) - - [ps9, ps10, ps11, ps12, ps13, ps14, ps15, ps16] - |> Enum.each(fn %{user: user, socket: socket} -> - Lobby.force_add_user_to_lobby(user.id, lobby_id) - # Need the sleep to ensure they all get added to the battle - :timer.sleep(50) - _tachyon_send(socket, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - end) - - # Clear the old ratings so we can make some new ones - old_ids = [u1, u2, u3, u4, u5, u6, u7, u8] |> Enum.map_join(",", fn u -> u.id end) - query = "DELETE FROM teiserver_account_ratings WHERE user_id IN (#{old_ids})" - query_result = Ecto.Adapters.SQL.query(Repo, query, []) - - assert elem(query_result, 0) == :ok, - message: "The delete query failed so new ratings could not be created" - - # higher numbered players have higher ratings - make_rating(u1.id, rating_type_id, 12) - make_rating(u2.id, rating_type_id, 15) - make_rating(u3.id, rating_type_id, 17) - make_rating(u4.id, rating_type_id, 20) - make_rating(u5.id, rating_type_id, 23) - make_rating(u6.id, rating_type_id, 25) - make_rating(u7.id, rating_type_id, 27) - make_rating(u8.id, rating_type_id, 30) - make_rating(u9.id, rating_type_id, 31) - make_rating(u10.id, rating_type_id, 32) - make_rating(u11.id, rating_type_id, 34) - make_rating(u12.id, rating_type_id, 39) - make_rating(u13.id, rating_type_id, 40) - make_rating(u14.id, rating_type_id, 41) - make_rating(u15.id, rating_type_id, 43) - make_rating(u16.id, rating_type_id, 49) - - # Clear rating caches - [u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14, u15, u16] - |> Enum.each(fn %{id: userid} -> - Teiserver.cache_delete(:teiserver_user_ratings, {userid, rating_type_id}) - end) - - # Leave the party - Account.move_client_to_party(u8.id, nil) - Account.move_client_to_party(u7.id, nil) - Account.move_client_to_party(u6.id, nil) - Account.move_client_to_party(u5.id, nil) - - :timer.sleep(50) - - # Assert we have no parties - [u1, u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12, u13, u14, u15, u16] - |> Enum.each(fn %{id: userid} -> - assert Account.get_client_by_id(userid).party_id == nil, - message: - "One or more of the users are currently in a party. At this stage of the test there should be no parties." - end) - - # Get some new balance - balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert Battle.get_lobby_balance_mode(lobby_id) == :grouped - assert balance_result.balance_mode == :grouped - - assert Enum.sort(balance_result.team_players[1]) == - Enum.sort([ - u16.id, - u13.id, - u11.id, - u10.id, - u7.id, - u6.id, - u4.id, - u1.id - ]) - - assert Enum.sort(balance_result.team_players[2]) == - Enum.sort([ - u15.id, - u14.id, - u12.id, - u9.id, - u8.id, - u5.id, - u3.id, - u2.id - ]) - - assert balance_result.ratings == %{1 => 239.0, 2 => 239.0} - assert balance_result.deviation == 0 - - # Now test that fuzzing happens - opts = [ - shuffle_first_pick: false, - allow_groups: true, - mean_diff_max: 20, - stddev_diff_max: 10, - rating_lower_boundary: 5, - rating_upper_boundary: 5, - max_deviation: 10, - fuzz_multiplier: 0.5 - ] - - balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert Battle.get_lobby_balance_mode(lobby_id) == :grouped - assert balance_result.balance_mode == :grouped - refute balance_result.ratings == %{1 => 239.0, 2 => 239.0} - - :timer.sleep(3000) - end - - test "server balance - ffa", %{ - lobby_id: lobby_id, - host: _host, - psocket: _psocket, - player: player - } do - # We don't want to use the player we start with, we want to number our players specifically - Lobby.remove_user_from_any_lobby(player.id) - - %{user: u1} = ps1 = new_user("FFA_Arbiter") |> tachyon_auth_setup() - %{user: u2} = ps2 = new_user("FFA_Brute") |> tachyon_auth_setup() - %{user: u3} = ps3 = new_user("FFA_Calamity") |> tachyon_auth_setup() - - rating_type_id = MatchRatingLib.rating_type_name_lookup()["FFA"] - - [ps1, ps2, ps3] - |> Enum.each(fn %{user: user, socket: socket} -> - Lobby.force_add_user_to_lobby(user.id, lobby_id) - # Need the sleep to ensure they all get added to the battle - :timer.sleep(50) - _tachyon_send(socket, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - end) - - # Create some ratings - # higher numbered players have higher ratings - make_rating(u1.id, rating_type_id, 20) - make_rating(u2.id, rating_type_id, 25) - make_rating(u3.id, rating_type_id, 30) - - # Wait for everybody to get added to the room - :timer.sleep(250) - - consul_state = Coordinator.call_consul(lobby_id, :get_all) - max_player_count = ConsulServer.get_max_player_count(consul_state) - assert max_player_count >= 3 - - assert Battle.list_lobby_players(lobby_id) |> Enum.count() == 3 - - opts = [ - shuffle_first_pick: false, - fuzz_multiplier: 0 - ] - - team_count = 3 - - balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert balance_result.team_players[1] == [u3.id] - assert balance_result.team_players[2] == [u2.id] - assert balance_result.team_players[3] == [u1.id] - assert balance_result.deviation == 17 - assert balance_result.ratings == %{1 => 30.0, 2 => 25.0, 3 => 20.0} - assert Battle.get_lobby_balance_mode(lobby_id) == :solo - - # Ensure cache works - assert Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) == balance_result - - # Ensure enabling groups won't break anything - opts = [ - shuffle_first_pick: false, - allow_groups: true, - mean_diff_max: 15, - stddev_diff_max: 10, - rating_lower_boundary: 5, - rating_upper_boundary: 5, - max_deviation: 10, - fuzz_multiplier: 0 - ] - - grouped_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert Map.drop(grouped_balance_result, [:hash, :time_taken, :logs]) == - Map.drop(balance_result, [:hash, :time_taken, :logs]) - - assert grouped_balance_result.hash != balance_result.hash - - :timer.sleep(3000) - end - - test "server balance - team ffa", %{ - lobby_id: lobby_id, - host: _host, - psocket: _psocket, - player: player - } do - # We don't want to use the player we start with, we want to number our players specifically - Lobby.remove_user_from_any_lobby(player.id) - - %{user: u1} = ps1 = new_user("Team_FFA_Arbiter") |> tachyon_auth_setup() - %{user: u2} = ps2 = new_user("Team_FFA_Brute") |> tachyon_auth_setup() - %{user: u3} = ps3 = new_user("Team_FFA_Calamity") |> tachyon_auth_setup() - %{user: u4} = ps4 = new_user("Team_FFA_Destroyer") |> tachyon_auth_setup() - %{user: u5} = ps5 = new_user("Team_FFA_Eagle") |> tachyon_auth_setup() - %{user: u6} = ps6 = new_user("Team_FFA_Fury") |> tachyon_auth_setup() - %{user: u7} = ps7 = new_user("Team_FFA_Garpike") |> tachyon_auth_setup() - %{user: u8} = ps8 = new_user("Team_FFA_Hound") |> tachyon_auth_setup() - %{user: u9} = ps9 = new_user("Team_FFA_Incisor") |> tachyon_auth_setup() - - # Sleep to allow the users to be correctly added, otherwise we get PK errors we'd not - # get in prod - :timer.sleep(1000) - - rating_type_id = MatchRatingLib.rating_type_name_lookup()["Team"] - - [ps1, ps2, ps3, ps4, ps5, ps6, ps7, ps8, ps9] - |> Enum.each(fn %{user: user, socket: socket} -> - Lobby.force_add_user_to_lobby(user.id, lobby_id) - # Need the sleep to ensure they all get added to the battle - :timer.sleep(50) - _tachyon_send(socket, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - end) - - # Create some ratings - # higher numbered players have higher ratings - make_rating(u1.id, rating_type_id, 20) - make_rating(u2.id, rating_type_id, 25) - make_rating(u3.id, rating_type_id, 30) - make_rating(u4.id, rating_type_id, 35) - make_rating(u5.id, rating_type_id, 36) - make_rating(u6.id, rating_type_id, 38) - make_rating(u7.id, rating_type_id, 47) - make_rating(u8.id, rating_type_id, 50) - make_rating(u9.id, rating_type_id, 51) - - # Wait for everybody to get added to the room - :timer.sleep(500) - - consul_state = Coordinator.call_consul(lobby_id, :get_all) - max_player_count = ConsulServer.get_max_player_count(consul_state) - assert max_player_count >= 9 - - assert Battle.list_lobby_players(lobby_id) |> Enum.count() == 9 - - opts = [ - shuffle_first_pick: false, - fuzz_multiplier: 0 - ] - - team_count = 3 - - balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert balance_result.team_players[1] == [u9.id, u4.id, u2.id] - assert balance_result.team_players[2] == [u8.id, u5.id, u1.id] - assert balance_result.team_players[3] == [u7.id, u6.id, u3.id] - assert balance_result.deviation == 3 - assert balance_result.ratings == %{1 => 111, 2 => 106, 3 => 115} - assert Battle.get_lobby_balance_mode(lobby_id) == :solo - - # Now do it grouped, these bounds mean it won't be able to find paired groups for - # the party - opts = [ - shuffle_first_pick: false, - allow_groups: true, - mean_diff_max: 15, - stddev_diff_max: 10, - rating_lower_boundary: 5, - rating_upper_boundary: 5, - max_deviation: 10, - fuzz_multiplier: 0 - ] - - grouped_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert Map.drop(grouped_balance_result, [:balance_mode, :hash, :time_taken, :logs]) == - Map.drop(balance_result, [:balance_mode, :hash, :time_taken, :logs]) - - assert grouped_balance_result.hash != balance_result.hash - - # Party time, we start with the two highest rated players being put on the same team - high_party = Account.create_party(u8.id) - Account.move_client_to_party(u7.id, high_party.id) - - # Sleep so we don't get a cached list of players when calculating the balance - :timer.sleep(520) - - party_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - # Balance should be mostly the same - assert Map.drop(grouped_balance_result, [:hash, :time_taken, :logs, :balance_mode]) == - Map.drop(balance_result, [:hash, :time_taken, :logs, :balance_mode]) - - refute party_balance_result.hash == balance_result.hash - - # This time groups will work - opts = [ - shuffle_first_pick: false, - allow_groups: true, - mean_diff_max: 150, - stddev_diff_max: 100, - rating_lower_boundary: 50, - rating_upper_boundary: 50, - max_deviation: 100, - fuzz_multiplier: 0 - ] - - grouped_balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - team_count, - opts - }) - - assert grouped_balance_result.team_players[1] == [u7.id, u8.id, u1.id] - assert grouped_balance_result.team_players[2] == [u6.id, u4.id, u5.id] - assert grouped_balance_result.team_players[3] == [u3.id, u2.id, u9.id] - assert grouped_balance_result.deviation == 7 - assert grouped_balance_result.ratings == %{1 => 117.0, 2 => 109.0, 3 => 106.0} - assert Battle.get_lobby_balance_mode(lobby_id) == :grouped - - :timer.sleep(3000) - end -end diff --git a/test/teiserver/coordinator/consul_chat_test.exs b/test/teiserver/coordinator/consul_chat_test.exs deleted file mode 100644 index a8c9c7ced..000000000 --- a/test/teiserver/coordinator/consul_chat_test.exs +++ /dev/null @@ -1,121 +0,0 @@ -defmodule Teiserver.Coordinator.ConsulChatTest do - @moduledoc false - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.{CacheUser, Client, Coordinator, Lobby} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - CacheUser.update_user(%{host | roles: ["Moderator"]}) - ClientLib.refresh_client(host.id) - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.force_add_user_to_lobby(player.id, lobby_id) - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv(hsocket) - - # Battlestatus message - _tachyon_recv(hsocket) - - # We set a welcome message because if the consul crashes it will reset the welcome-message - # also, if a function doesn't return a map then the state will no longer be a map - _tachyon_send(hsocket, %{ - cmd: "c.lobby.message", - message: "$welcome-message This is the welcome message" - }) - - message = Coordinator.call_consul(lobby_id, {:get, :welcome_message}) - assert message == "This is the welcome message" - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - test "standard messages", %{lobby_id: lobby_id, psocket: psocket} do - data = %{cmd: "c.lobby.message", message: "Chat chat chat 1"} - _tachyon_send(psocket, data) - - data = %{cmd: "c.lobby.message", message: "Chat chat chat 2"} - _tachyon_send(psocket, data) - - data = %{cmd: "c.lobby.message", message: "Chat chat chat 3"} - _tachyon_send(psocket, data) - - message = Coordinator.call_consul(lobby_id, {:get, :welcome_message}) - assert message == "This is the welcome message" - end - - test "ring flood", %{lobby_id: lobby_id, player: player1, psocket: psocket} do - data = %{cmd: "c.lobby.message", message: "!ring other_player"} - _tachyon_send(psocket, data) - - data = %{cmd: "c.lobby.message", message: "!ring other_player"} - _tachyon_send(psocket, data) - - data = %{cmd: "c.lobby.message", message: "!ring other_player"} - _tachyon_send(psocket, data) - - timestamps = Coordinator.call_consul(lobby_id, {:get, :ring_timestamps}) - player1_stamps = timestamps[player1.id] - assert Enum.count(player1_stamps) == 3 - - data = %{cmd: "c.lobby.message", message: "!ring other_player"} - _tachyon_send(psocket, data) - - timestamps = Coordinator.call_consul(lobby_id, {:get, :ring_timestamps}) - player1_stamps = timestamps[player1.id] - assert Enum.count(player1_stamps) == 4 - - flood_count = Teiserver.cache_get(:teiserver_login_count, player1.id) - assert flood_count == 1 - - data = %{cmd: "c.lobby.message", message: "!ring other_player"} - _tachyon_send(psocket, data) - - timestamps = Coordinator.call_consul(lobby_id, {:get, :ring_timestamps}) - player1_stamps = timestamps[player1.id] - assert Enum.count(player1_stamps) == 5 - - flood_count = Teiserver.cache_get(:teiserver_login_count, player1.id) - assert flood_count > 1 - - message = Coordinator.call_consul(lobby_id, {:get, :welcome_message}) - assert message == "This is the welcome message" - end -end diff --git a/test/teiserver/coordinator/consul_commands_test.exs b/test/teiserver/coordinator/consul_commands_test.exs deleted file mode 100644 index 0dbee785f..000000000 --- a/test/teiserver/coordinator/consul_commands_test.exs +++ /dev/null @@ -1,1212 +0,0 @@ -defmodule Teiserver.Coordinator.ConsulCommandsTest do - @moduledoc false - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.Common.PubsubListener - alias Teiserver.Game.MatchRatingLib - alias Teiserver.{Account, Battle, CacheUser, Client, Coordinator, Lobby} - alias Teiserver.Coordinator.ConsulServer - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1, _tachyon_recv_until: 1] - - # this may have to go completely, or needs *serious* changes since it's based - # on old tachyon version (based on direct tls socket and custom proto, not ws) - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - CacheUser.update_user(%{host | roles: ["Moderator"]}) - ClientLib.refresh_client(host.id) - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - listener = PubsubListener.new_listener(["teiserver_lobby_chat:#{lobby_id}"]) - - # Player needs to be added to the battle - Lobby.add_user_to_battle(player.id, lobby_id) - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - _tachyon_recv_until(psocket) - - # Add user message - _tachyon_recv_until(hsocket) - - # Battlestatus message - _tachyon_recv_until(hsocket) - - {:ok, - hsocket: hsocket, - psocket: psocket, - host: host, - player: player, - lobby_id: lobby_id, - listener: listener} - end - - defp make_rating(userid, rating_type_id, rating_value) do - {:ok, _} = - Account.create_rating(%{ - user_id: userid, - rating_type_id: rating_type_id, - rating_value: rating_value, - skill: rating_value, - uncertainty: 0, - leaderboard_rating: rating_value, - last_updated: Timex.now() - }) - end - - test "non existent command", %{hsocket: hsocket} do - data = %{cmd: "c.lobby.message", message: "$creativecommandname"} - _tachyon_send(hsocket, data) - - [reply] = _tachyon_recv(hsocket) - assert reply["message"] == "No command of name 'creativecommandname'" - end - - test "non allowed command", %{lobby_id: lobby_id, psocket: psocket, player: player} do - Lobby.force_add_user_to_lobby(player.id, lobby_id) - player_client = Account.get_client_by_id(player.id) - - Client.update( - %{player_client | player: false, ready: false}, - :client_updated_battlestatus - ) - - _tachyon_recv(psocket) - - data = %{cmd: "c.lobby.message", message: "$specunready"} - _tachyon_send(psocket, data) - - [reply] = _tachyon_recv(psocket) - assert reply["message"] == "You are not allowed to use the 'specunready' command (host only)" - - data = %{cmd: "c.lobby.message", message: "$meme"} - _tachyon_send(psocket, data) - - [reply] = _tachyon_recv(psocket) - assert reply["message"] == "You are not allowed to use the 'meme' command (boss only)" - end - - test "specunready", %{lobby_id: lobby_id, player: player1, hsocket: hsocket} do - %{user: player2} = tachyon_auth_setup() - - # Add player2 to the battle but as a spectator - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - player_client = Account.get_client_by_id(player2.id) - - Client.update( - %{player_client | player: false, ready: false}, - :client_updated_battlestatus - ) - - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) |> Map.get(:ready) end) - - assert readies == [false, false] - - data = %{cmd: "c.lobby.message", message: "$specunready"} - _tachyon_send(hsocket, data) - - # Now we check they are ready or they're a spectator - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) end) - |> Enum.map(fn c -> c.player == false or c.ready == true end) - - assert readies == [true, true] - - # Unready both again - player_client = Account.get_client_by_id(player1.id) - Client.update(%{player_client | ready: false}, :client_updated_battlestatus) - - player_client = Account.get_client_by_id(player2.id) - Client.update(%{player_client | ready: false}, :client_updated_battlestatus) - - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) |> Map.get(:ready) end) - - assert readies == [false, false] - end - - test "makeready", %{lobby_id: lobby_id, player: player1, hsocket: hsocket} do - %{user: player2} = tachyon_auth_setup() - - # Add player2 to the battle but as a spectator - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - player_client = Account.get_client_by_id(player2.id) - - Client.update( - %{player_client | player: true, ready: false}, - :client_updated_battlestatus - ) - - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) |> Map.get(:ready) end) - - assert readies == [false, false] - - data = %{cmd: "c.lobby.message", message: "$makeready"} - _tachyon_send(hsocket, data) - - # Now we get the ready statuses - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) |> Map.get(:ready) end) - - assert readies == [true, true] - - # Unready both again - player_client = Account.get_client_by_id(player1.id) - Client.update(%{player_client | ready: false}, :client_updated_battlestatus) - - player_client = Account.get_client_by_id(player2.id) - Client.update(%{player_client | ready: false}, :client_updated_battlestatus) - - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) |> Map.get(:ready) end) - - assert readies == [false, false] - - # Now make one of them ready - data = %{cmd: "c.lobby.message", message: "$makeready ##{player1.id}"} - _tachyon_send(hsocket, data) - - readies = - Battle.get_lobby(lobby_id) - |> Map.get(:players) - |> Enum.map(fn userid -> Account.get_client_by_id(userid) |> Map.get(:ready) end) - - assert readies == [false, true] - end - - test "specafk", %{player: player1, psocket: psocket1, hsocket: hsocket, lobby_id: lobby_id} do - %{socket: psocket2, user: player2} = tachyon_auth_setup() - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - player_client1 = Account.get_client_by_id(player1.id) - - Client.update( - %{player_client1 | player: true}, - :client_updated_battlestatus - ) - - player_client2 = Account.get_client_by_id(player2.id) - - Client.update( - %{player_client2 | player: true}, - :client_updated_battlestatus - ) - - player_client1 = Account.get_client_by_id(player1.id) - player_client2 = Account.get_client_by_id(player2.id) - assert player_client1.player == true - assert player_client2.player == true - - :timer.sleep(1000) - - _ = _tachyon_recv_until(hsocket) - _ = _tachyon_recv_until(psocket1) - _ = _tachyon_recv_until(psocket2) - - # Say the command - data = %{cmd: "c.lobby.message", message: "$specafk"} - _tachyon_send(hsocket, data) - - # Status update for the first, can happen in either order - [reply1] = _tachyon_recv(hsocket) - assert reply1["cmd"] == "s.lobby.updated_client_battlestatus" - assert reply1["client"]["userid"] == player2.id or reply1["client"]["userid"] == player1.id - - # And now the other - [reply2] = _tachyon_recv(hsocket) - assert reply2["cmd"] == "s.lobby.updated_client_battlestatus" - assert reply2["client"]["userid"] == player2.id or reply2["client"]["userid"] == player1.id - - # Ensure it wasn't the same user twice - assert reply1["client"]["userid"] != reply2["client"]["userid"] - - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.say" - assert reply["message"] == "$specafk" - - # Both players should get a message from the coordinator - [reply] = _tachyon_recv(psocket1) - assert reply["cmd"] == "s.communication.received_direct_message" - - assert reply["message"] == - "The lobby you are in is conducting an AFK check, please respond with 'hello' here to show you are not afk or just type something into the lobby chat." - - [reply] = _tachyon_recv(psocket2) - assert reply["cmd"] == "s.communication.received_direct_message" - - assert reply["message"] == - "The lobby you are in is conducting an AFK check, please respond with 'hello' here to show you are not afk or just type something into the lobby chat." - - # Check consul state - pid = Coordinator.get_consul_pid(lobby_id) - - state = :sys.get_state(pid) - assert state.afk_check_list == [player2.id, player1.id] - assert state.afk_check_at != nil - - send(pid, :tick) - - state = :sys.get_state(pid) - assert state.afk_check_list == [player2.id, player1.id] - assert state.afk_check_at != nil - - # Send the wrong message - data = %{ - cmd: "c.communication.send_direct_message", - message: "this is the wrong message", - recipient_id: Coordinator.get_coordinator_userid() - } - - _tachyon_send(psocket1, data) - - send(pid, :tick) - state = :sys.get_state(pid) - assert state.afk_check_list == [player2.id, player1.id] - assert state.afk_check_at != nil - - # Now send the correct message - data = %{ - cmd: "c.communication.send_direct_message", - message: "hello", - recipient_id: Coordinator.get_coordinator_userid() - } - - _tachyon_send(psocket1, data) - - send(pid, :tick) - state = :sys.get_state(pid) - assert state.afk_check_list == [player2.id] - assert state.afk_check_at != nil - - _ = _tachyon_recv_until(hsocket) - - # Now we say time has elapsed - send(pid, {:put, :afk_check_at, 1}) - send(pid, :tick) - - state = :sys.get_state(pid) - assert state.afk_check_list == [] - assert state.afk_check_at == nil - - player_client1 = Account.get_client_by_id(player1.id) - player_client2 = Account.get_client_by_id(player2.id) - assert player_client1.player == true - assert player_client2.player == false - - # What has happened now? - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.updated_client_battlestatus" - assert reply["client"]["userid"] == player2.id - assert reply["client"]["player"] == false - - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.say" - assert reply["message"] == "AFK-check is now complete, 1 player(s) were found to be afk" - end - - test "pull user", %{lobby_id: lobby_id, hsocket: hsocket, host: _host} do - %{user: player2, socket: psocket} = tachyon_auth_setup() - - data = %{cmd: "c.lobby.message", message: "$pull ##{player2.id}"} - _tachyon_send(hsocket, data) - - [reply] = _tachyon_recv(psocket) - assert reply["cmd"] == "s.lobby.joined" - assert reply["lobby"]["id"] == lobby_id - end - - test "pull users", %{lobby_id: lobby_id, hsocket: hsocket} do - %{user: player2, socket: socket2} = tachyon_auth_setup() - %{user: player3, socket: socket3} = tachyon_auth_setup() - - data = %{cmd: "c.lobby.message", message: "$pull ##{player2.id} ##{player3.id}"} - _tachyon_send(hsocket, data) - - [reply2] = _tachyon_recv(socket2) - assert reply2["cmd"] == "s.lobby.joined" - assert reply2["lobby"]["id"] == lobby_id - - [reply3] = _tachyon_recv(socket3) - assert reply3["cmd"] == "s.lobby.joined" - assert reply3["lobby"]["id"] == lobby_id - end - - # TODO: settag - - test "explain and bstatus", %{lobby_id: lobby_id, hsocket: hsocket, host: host, player: player} do - # Set fuzzer to 0 or we get inconsistent values and our test breaks - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$set fuzz_multiplier 0"}) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.say", - "lobby_id" => lobby_id, - "message" => "$set fuzz_multiplier 0", - "sender_id" => host.id - } - - rating_type_id = MatchRatingLib.rating_type_name_lookup()["Duel"] - make_rating(player.id, rating_type_id, 20) - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$%explain"}) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - [ - "---------------------------", - "No balance has been created for this room", - "---------------------------" - ] - |> Enum.join("\n"), - "sender_id" => Coordinator.get_coordinator_userid() - } - - balance_result = - Coordinator.call_balancer(lobby_id, { - :make_balance, - 2, - [allow_groups: true] - }) - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$%explain"}) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - [ - "---------------------------", - "Balance logs, mode: solo", - "Tried grouped mode, got a deviation of 100 and reverted to solo mode", - "Picked #{player.name} for team 1, adding 16.67 points for new total of 16.67", - "Deviation of: 100", - "Team 1 - sum: 16.7, mean: 16.7, stdev: 0.0", - "Team 2 - sum: 0.0, mean: 0.0, stdev: 0.0", - "Time taken: #{balance_result.time_taken}us", - "---------------------------" - ] - |> Enum.join("\n"), - "sender_id" => Coordinator.get_coordinator_userid() - } - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$%bstatus"}) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - [ - "--------------------------- Balancer status ---------------------------", - "algorithm: loser_picks", - "fuzz_multiplier: 0", - "hashes: 1", - "max_deviation: 10", - "mean_diff_max: 5", - "rating_lower_boundary: 3", - "rating_upper_boundary: 5", - "shuffle_first_pick: true", - "stddev_diff_max: 3" - ] - |> Enum.join("\n"), - "sender_id" => Coordinator.get_coordinator_userid() - } - end - - test "ratingtoplay", %{lobby_id: lobby_id, hsocket: hsocket} do - # Minimum - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 0 - - data = %{cmd: "c.lobby.message", message: "$minratinglevel 3"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 3 - - data = %{cmd: "c.lobby.message", message: "$minratinglevel Xy"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 3 - - # Maximum - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 1000 - - data = %{cmd: "c.lobby.message", message: "$maxratinglevel 13"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13 - - data = %{cmd: "c.lobby.message", message: "$maxratinglevel Xy"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 13 - - # Now try to set each the other side of the other - data = %{cmd: "c.lobby.message", message: "$maxratinglevel 1"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 4 - - data = %{cmd: "c.lobby.message", message: "$maxratinglevel 16"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 16 - - data = %{cmd: "c.lobby.message", message: "$minratinglevel 20"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 15 - - data = %{cmd: "c.lobby.message", message: "$setratinglevels 7 9"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 7 - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 9 - - data = %{cmd: "c.lobby.message", message: "$setratinglevels 50 33"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 33 - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 50 - - data = %{cmd: "c.lobby.message", message: "$resetratinglevels"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rating_to_play}) == 0 - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rating_to_play}) == 1000 - end - - test "ranktoplay", %{lobby_id: lobby_id, hsocket: hsocket} do - # Minimum - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 0 - - data = %{cmd: "c.lobby.message", message: "$minranklevel 3"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 3 - - data = %{cmd: "c.lobby.message", message: "$minranklevel Xy"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 3 - - # Maximum - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 1000 - - data = %{cmd: "c.lobby.message", message: "$maxranklevel 13"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 13 - - data = %{cmd: "c.lobby.message", message: "$maxranklevel Xy"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 13 - - # Now try to set each the other side of the other - data = %{cmd: "c.lobby.message", message: "$maxranklevel 1"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 4 - - data = %{cmd: "c.lobby.message", message: "$maxranklevel 16"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 16 - - data = %{cmd: "c.lobby.message", message: "$minranklevel 20"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 15 - - data = %{cmd: "c.lobby.message", message: "$setranklevels 7 9"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 7 - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 9 - - data = %{cmd: "c.lobby.message", message: "$setranklevels 50 33"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 33 - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 50 - - data = %{cmd: "c.lobby.message", message: "$resetranklevels"} - _tachyon_send(hsocket, data) - :timer.sleep(500) - - assert Coordinator.call_consul(lobby_id, {:get, :minimum_rank_to_play}) == 0 - assert Coordinator.call_consul(lobby_id, {:get, :maximum_rank_to_play}) == 1000 - end - - test "timeout", %{host: host, player: player, hsocket: hsocket, lobby_id: lobby_id} do - player_client = Account.get_client_by_id(player.id) - assert player_client.player == true - - data = %{cmd: "c.lobby.message", message: "$timeout #{player.name} Because I said so"} - _tachyon_send(hsocket, data) - - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == nil - - # Check ban state (we added this after bans, don't want to get them confused) - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - assert bans == %{} - - timeouts = Coordinator.call_consul(lobby_id, {:get, :timeouts}) - assert timeouts == %{player.id => %{by: host.id, level: :banned, reason: "Because I said so"}} - - assert Coordinator.call_consul(lobby_id, {:request_user_join_lobby, player.id}) == - {false, "Because I said so"} - - # Check timeout state - timeouts = Coordinator.call_consul(lobby_id, {:get, :timeouts}) - assert timeouts == %{player.id => %{by: host.id, level: :banned, reason: "Because I said so"}} - - # Now we say the match ended - Coordinator.cast_consul(lobby_id, :match_stop) - - assert Coordinator.call_consul(lobby_id, {:request_user_join_lobby, player.id}) == {true, nil} - - timeouts = Coordinator.call_consul(lobby_id, {:get, :timeouts}) - assert timeouts == %{} - end - - test "kick by name", %{player: player, hsocket: hsocket, lobby_id: lobby_id} do - player_client = Account.get_client_by_id(player.id) - assert player_client.player == true - - data = %{cmd: "c.lobby.message", message: "$lobbykick #{player.name}"} - _tachyon_send(hsocket, data) - - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == nil - - # Check ban state - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - assert bans == %{} - end - - test "ban by name", %{host: host, player: player, hsocket: hsocket, lobby_id: lobby_id} do - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == lobby_id - - data = %{cmd: "c.lobby.message", message: "$lobbyban #{player.name} Because I said so"} - _tachyon_send(hsocket, data) - - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == nil - - # Check ban state - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - assert bans == %{player.id => %{by: host.id, level: :banned, reason: "Because I said so"}} - end - - test "ban by partial name", %{host: host, player: player, hsocket: hsocket, lobby_id: lobby_id} do - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == lobby_id - - data = %{cmd: "c.lobby.message", message: "$lobbyban #{player.name |> String.slice(0, 5)}"} - _tachyon_send(hsocket, data) - - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == nil - - # Check ban state - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - assert bans == %{player.id => %{by: host.id, level: :banned, reason: "Banned"}} - end - - test "error with no name", %{player: player, hsocket: hsocket, lobby_id: lobby_id} do - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == lobby_id - - data = %{cmd: "c.lobby.message", message: "$kick noname"} - _tachyon_send(hsocket, data) - - # They should not be kicked, we expect no other errors at this stage - player_client = Account.get_client_by_id(player.id) - assert player_client.lobby_id == lobby_id - end - - test "ban multiple", %{host: host, player: player1, hsocket: hsocket, lobby_id: lobby_id} do - %{user: player2} = tachyon_auth_setup() - %{user: player3} = tachyon_auth_setup() - - # Add player2 to the battle but not player 3 - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - Account.merge_update_client(player1.id, %{player: true}) - Account.merge_update_client(player2.id, %{player: true}) - - player1_client = Account.get_client_by_id(player1.id) - player2_client = Account.get_client_by_id(player2.id) - assert player1_client.player == true - assert player1_client.lobby_id == lobby_id - assert player2_client.lobby_id == lobby_id - - data = %{ - cmd: "c.lobby.message", - message: - "$lobbybanmult #{player1.name} #{player2.name} #{player3.name} no_player_of_this_name" - } - - _tachyon_send(hsocket, data) - - player1_client = Account.get_client_by_id(player1.id) - player2_client = Account.get_client_by_id(player2.id) - assert player1_client.lobby_id == nil - assert player2_client.lobby_id == nil - - # Check ban state - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - - assert bans == %{ - player1.id => %{by: host.id, level: :banned, reason: "Banned"}, - player2.id => %{by: host.id, level: :banned, reason: "Banned"}, - player3.id => %{by: host.id, level: :banned, reason: "Banned"} - } - - # Now unban player 3 - data = %{cmd: "c.lobby.message", message: "$unban #{player3.name}"} - _tachyon_send(hsocket, data) - - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - - assert bans == %{ - player1.id => %{by: host.id, level: :banned, reason: "Banned"}, - player2.id => %{by: host.id, level: :banned, reason: "Banned"} - } - - # Now test it with a reason given - data = %{ - cmd: "c.lobby.message", - message: - "$lobbybanmult #{player1.name} #{player2.name} #{player3.name} no_player_of_this_name !! Reason given is xyz" - } - - _tachyon_send(hsocket, data) - - bans = Coordinator.call_consul(lobby_id, {:get, :bans}) - - assert bans == %{ - player1.id => %{by: host.id, level: :banned, reason: "Reason given is xyz"}, - player2.id => %{by: host.id, level: :banned, reason: "Reason given is xyz"}, - player3.id => %{by: host.id, level: :banned, reason: "Reason given is xyz"} - } - end - - test "set_player_limit", %{lobby_id: lobby_id, hsocket: hsocket, host: host} do - player_limit = Coordinator.call_consul(lobby_id, {:get, :player_limit}) - assert player_limit == 16 - - data = %{cmd: "c.lobby.message", message: "$playerlimit 16"} - _tachyon_send(hsocket, data) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.say", - "lobby_id" => lobby_id, - "message" => "$playerlimit 16", - "sender_id" => host.id - } - - # Check state - player_limit = Coordinator.call_consul(lobby_id, {:get, :player_limit}) - assert player_limit == 16 - end - - test "roll", %{hsocket: hsocket, host: host} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$roll badly"}) - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.received_lobby_direct_announce" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - - assert reply["message"] == - "Format not recognised, please consult the help for this command for more information." - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$roll 1D1"}) - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.say" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - assert reply["message"] == "#{host.name} rolled 1D1 and got a result of: 1" - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$roll 50D1"}) - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.say" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - assert reply["message"] == "#{host.name} rolled 50D1 and got a result of: 50" - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$roll 100"}) - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.say" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - assert reply["message"] =~ "#{host.name} rolled for a number between 1 and 100, they got: " - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$roll 20 100"}) - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.say" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - assert reply["message"] =~ "#{host.name} rolled for a number between 20 and 100, they got: " - end - - test "status", %{lobby_id: lobby_id, hsocket: hsocket} do - data = %{cmd: "c.lobby.message", message: "$status"} - _tachyon_send(hsocket, data) - - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.communication.received_direct_message" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - - assert reply["message"] |> String.split("\n") |> Enum.slice(0, 5) == [ - "--------------------------- Lobby status ---------------------------", - "Status for battle ##{lobby_id}", - "Locks: ", - "Gatekeeper: default", - "Join queue: (size: 0)" - ] - end - - test "help", %{lobby_id: lobby_id, hsocket: hsocket, host: host} do - data = %{cmd: "c.lobby.message", message: "$help"} - _tachyon_send(hsocket, data) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.say", - "lobby_id" => lobby_id, - "message" => "$help", - "sender_id" => host.id - } - - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.communication.received_direct_message" - assert reply["sender_id"] == Coordinator.get_coordinator_userid() - assert reply["message"] |> String.split("\n") |> Enum.count() > 5 - end - - test "rename", %{lobby_id: lobby_id, hsocket: hsocket, host: host} do - data = %{cmd: "c.lobby.message", message: "$rename New Lobby Name "} - _tachyon_send(hsocket, data) - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => %{ - "name" => "New Lobby Name" - } - } - - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.say", - "message" => "$rename New Lobby Name", - "sender_id" => host.id, - "lobby_id" => lobby_id - } - - assert Battle.get_lobby(lobby_id).name == "New Lobby Name" - end - - test "password? weth no password", %{lobby_id: lobby_id, hsocket: hsocket} do - coordinator_id = Coordinator.get_coordinator_userid() - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$password?"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.received_lobby_direct_announce", - "message" => "This lobby has no password set", - "sender_id" => coordinator_id - } - - assert Battle.get_lobby(lobby_id).password == nil - assert Battle.get_lobby(lobby_id).passworded == false - end - - test "passthrough", %{hsocket: hsocket, listener: listener} do - PubsubListener.get(listener) - - data = %{cmd: "c.lobby.message", message: "$non-existing command"} - _tachyon_send(hsocket, data) - messages = PubsubListener.get(listener) - assert messages == [] - - reply = _tachyon_recv(hsocket) - - assert reply == [ - %{ - "cmd" => "s.lobby.received_lobby_direct_announce", - "message" => "No command of name 'non-existing'", - "sender_id" => Coordinator.get_coordinator_userid() - } - ] - end - - test "join_queue", %{ - lobby_id: lobby_id, - host: host, - hsocket: hsocket, - psocket: _psocket, - player: player - } do - consul_pid = Coordinator.get_consul_pid(lobby_id) - - # We don't want to use the player we start with, we want to number our players specifically - Lobby.remove_user_from_any_lobby(player.id) - - _tachyon_send(hsocket, %{ - cmd: "c.lobby_host.update_host_status", - boss: nil, - teamsize: 2, - teamcount: 2 - }) - - state = Coordinator.call_consul(lobby_id, :get_all) - max_player_count = ConsulServer.get_max_player_count(state) - assert max_player_count == 4 - - # At the moment we are hard coding the join queue to 8v8s until we - # add something to get the player count limit - ps1 = %{user: player1, socket: _socket1} = tachyon_auth_setup() - ps2 = %{user: player2, socket: _socket2} = tachyon_auth_setup() - ps3 = %{user: player3, socket: _socket3} = tachyon_auth_setup() - ps4 = %{user: player4, socket: _socket4} = tachyon_auth_setup() - - %{user: player5, socket: socket5} = tachyon_auth_setup() - %{user: player6, socket: socket6} = tachyon_auth_setup() - %{user: player7, socket: socket7} = tachyon_auth_setup() - %{user: player8, socket: _socket8} = tachyon_auth_setup() - - # The 50ms delays are to allow it to add them in the correct order - [ps1, ps2, ps3, ps4] - |> Enum.each(fn %{user: user, socket: socket} -> - Lobby.force_add_user_to_lobby(user.id, lobby_id) - :timer.sleep(50) - _tachyon_send(socket, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - end) - - Lobby.force_add_user_to_lobby(player5.id, lobby_id) - :timer.sleep(50) - Lobby.force_add_user_to_lobby(player6.id, lobby_id) - :timer.sleep(50) - Lobby.force_add_user_to_lobby(player7.id, lobby_id) - :timer.sleep(50) - Lobby.force_add_user_to_lobby(player8.id, lobby_id) - :timer.sleep(50) - - member_ids = Battle.get_lobby_member_list(lobby_id) - - assert member_ids == [ - player8.id, - player7.id, - player6.id, - player5.id, - player4.id, - player3.id, - player2.id, - player1.id - ] - - player_ids = - Battle.list_lobby_players(lobby_id) - |> Enum.map(fn %{userid: userid} -> userid end) - - assert player_ids == [player4.id, player3.id, player2.id, player1.id] - - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [] - - # # Add to the queue - _tachyon_send(socket5, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket6, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket7, %{cmd: "c.lobby.message", message: "$joinq"}) - - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player5.id, player6.id, player7.id] - - # Now leave the queue - _tachyon_send(socket6, %{cmd: "c.lobby.message", message: "$leaveq"}) - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player5.id, player7.id] - - # And the battle - _tachyon_send(socket7, %{cmd: "c.lobby.leave"}) - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player5.id] - - # Now we need one of the players to become a spectator and open up a slot! - assert Account.get_client_by_id(player5.id).player == false - - _tachyon_send(ps1.socket, %{ - cmd: "c.lobby.update_status", - client: %{player: false, ready: false} - }) - - :timer.sleep(100) - send(consul_pid, :tick) - - consul_state = :sys.get_state(consul_pid) - assert consul_state.join_queue == [] - assert Account.get_client_by_id(player5.id).player == true - - # Now get users 6 and 7 back in - Lobby.force_add_user_to_lobby(player6.id, lobby_id) - Lobby.force_add_user_to_lobby(player7.id, lobby_id) - - # Joinq again - _tachyon_send(socket5, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket6, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket7, %{cmd: "c.lobby.message", message: "$joinq"}) - - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player6.id, player7.id] - - # Make player2 not a player - _tachyon_send(ps2.socket, %{ - cmd: "c.lobby.update_status", - client: %{player: false, ready: false} - }) - - # Shouldn't be an update just yet - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player6.id, player7.id] - - # Call the tick function, 6 is now a player so should be removed from the queue - Coordinator.cast_consul(lobby_id, :tick) - - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player7.id] - - # Finally we want to test the VIP command - # Clear the messages from the host socket - _tachyon_recv_until(hsocket) - - data = %{cmd: "c.lobby.message", message: "$vip #{player8.name}"} - _tachyon_send(hsocket, data) - - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player8.id, player7.id] - - result = _tachyon_recv(hsocket) - - assert result == [ - %{ - "cmd" => "s.lobby.say", - "lobby_id" => lobby_id, - "message" => "$vip #{player8.name}", - "sender_id" => host.id - } - ] - - result = _tachyon_recv(hsocket) - - assert result == [ - %{ - "cmd" => "s.lobby.announce", - "lobby_id" => lobby_id, - "message" => "#{host.name} placed #{player8.name} at the front of the join queue", - "sender_id" => Coordinator.get_coordinator_userid() - } - ] - - # Now do it for #7 - data = %{cmd: "c.lobby.message", message: "$vip #{player7.name}"} - _tachyon_send(hsocket, data) - - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player7.id, player8.id] - end - - test "join_queue_on_full_game", %{lobby_id: lobby_id, hsocket: hsocket, player: existing_player} do - # Limit player count to 2 (1v1) - _tachyon_send(hsocket, %{ - cmd: "c.lobby_host.update_host_status", - boss: nil, - teamsize: 1, - teamcount: 2 - }) - - state = Coordinator.call_consul(lobby_id, :get_all) - max_player_count = ConsulServer.get_max_player_count(state) - assert max_player_count == 2 - - Lobby.kick_user_from_battle(existing_player.id, lobby_id) - - # Add the players - %{user: player1, socket: socket1} = tachyon_auth_setup() - %{user: player2, socket: socket2} = tachyon_auth_setup() - %{user: player3, socket: socket3} = tachyon_auth_setup() - - Lobby.force_add_user_to_lobby(player1.id, lobby_id) - Lobby.force_add_user_to_lobby(player2.id, lobby_id) - Lobby.force_add_user_to_lobby(player3.id, lobby_id) - :timer.sleep(50) - - # Players 2 and 3 are playing a 1v1, player 1 is a not a player - _tachyon_send(socket1, %{cmd: "c.lobby.update_status", client: %{player: false, ready: false}}) - - _tachyon_send(socket2, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - _tachyon_send(socket3, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - - assert Account.get_client_by_id(player1.id).player == false - assert Account.get_client_by_id(player2.id).player == true - assert Account.get_client_by_id(player3.id).player == true - - # Queue should be empty at start - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [] - - # Player 1 now wants to join - _tachyon_send(socket1, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - - # And added to the join queue - assert Account.get_client_by_id(player1.id).player == false - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player1.id] - end - - test "shuffle", %{lobby_id: lobby_id, hsocket: hsocket, player: existing_player} do - # Limit player count to 4 (2v2) - _tachyon_send(hsocket, %{ - cmd: "c.lobby_host.update_host_status", - boss: nil, - teamsize: 2, - teamcount: 2 - }) - - Lobby.kick_user_from_battle(existing_player.id, lobby_id) - - state = Coordinator.call_consul(lobby_id, :get_all) - max_player_count = ConsulServer.get_max_player_count(state) - assert max_player_count == 4 - - # Add the players - %{user: player1, socket: socket1} = tachyon_auth_setup() - CacheUser.add_roles(player1.id, ["VIP", "Streamer"]) - - %{user: player2, socket: socket2} = tachyon_auth_setup() - %{user: player3, socket: socket3} = tachyon_auth_setup() - %{user: player4, socket: socket4} = tachyon_auth_setup() - %{user: player5, socket: socket5} = tachyon_auth_setup() - %{user: player6, socket: socket6} = tachyon_auth_setup() - %{user: player7, socket: socket7} = tachyon_auth_setup() - %{user: player8, socket: socket8} = tachyon_auth_setup() - %{user: player9, socket: socket9} = tachyon_auth_setup() - - Lobby.force_add_user_to_lobby(player1.id, lobby_id) - Lobby.force_add_user_to_lobby(player2.id, lobby_id) - Lobby.force_add_user_to_lobby(player3.id, lobby_id) - Lobby.force_add_user_to_lobby(player4.id, lobby_id) - Lobby.force_add_user_to_lobby(player5.id, lobby_id) - Lobby.force_add_user_to_lobby(player6.id, lobby_id) - Lobby.force_add_user_to_lobby(player7.id, lobby_id) - Lobby.force_add_user_to_lobby(player8.id, lobby_id) - Lobby.force_add_user_to_lobby(player9.id, lobby_id) - :timer.sleep(1000) - - # All of them want to be players - _tachyon_send(socket1, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket2, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket3, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket4, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket5, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket6, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket7, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket8, %{cmd: "c.lobby.message", message: "$joinq"}) - _tachyon_send(socket9, %{cmd: "c.lobby.message", message: "$joinq"}) - :timer.sleep(1000) - - assert Account.get_client_by_id(player1.id).player == true - assert Account.get_client_by_id(player2.id).player == true - assert Account.get_client_by_id(player3.id).player == true - assert Account.get_client_by_id(player4.id).player == true - - assert Account.get_client_by_id(player5.id).player == false - assert Account.get_client_by_id(player6.id).player == false - assert Account.get_client_by_id(player7.id).player == false - assert Account.get_client_by_id(player8.id).player == false - assert Account.get_client_by_id(player9.id).player == false - - # player_list = - # Teiserver.Coordinator.ConsulServer.list_players(%{lobby_id: lobby_id}) - # |> Enum.map(fn %{userid: userid} -> userid end) - - # Queue should be empty at start - queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - assert queue == [player5.id, player6.id, player7.id, player8.id] - - # # Player 1 now wants to join - # _tachyon_send(socket1, %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}}) - - # # And added to the join queue - # assert Account.get_client_by_id(player1.id).player == false - # queue = Coordinator.call_consul(lobby_id, {:get, :join_queue}) - # assert queue == [player1.id] - end -end diff --git a/test/teiserver/coordinator/coordinator_commands_test.exs b/test/teiserver/coordinator/coordinator_commands_test.exs deleted file mode 100644 index fd030501d..000000000 --- a/test/teiserver/coordinator/coordinator_commands_test.exs +++ /dev/null @@ -1,243 +0,0 @@ -defmodule Teiserver.Coordinator.CoordinatorCommandsTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{CacheUser, Coordinator, Account} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1, new_user: 0] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: socket, user: user} = tachyon_auth_setup() - - coordinator_userid = Coordinator.get_coordinator_userid() - - {:ok, socket: socket, user: user, coordinator_userid: coordinator_userid} - end - - test "no command", %{socket: socket} do - message_coordinator(socket, "$no_command_here or here") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - # It's not a valid command and thus we ignore it currently - reply = _tachyon_recv(socket) - assert reply == :timeout - end - - test "non existent command", %{socket: socket} do - message_coordinator(socket, "$creativecommandname") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - assert String.contains?(message, "No command of name 'creativecommandname'") - end - - test "help", %{socket: socket, user: user} do - message_coordinator(socket, "$help") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - assert String.contains?(message, "$whoami") - - # Moderator help test - CacheUser.update_user(%{user | moderator: true}) - message_coordinator(socket, "$help") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - - assert String.contains?(message, "$whoami") - assert String.contains?(message, "$pull ") - assert String.contains?(message, "$success") - end - - test "help not existing", %{socket: socket} do - message_coordinator(socket, "$help give 10 corjugg Lexon") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - assert message == "No commands matching that filter." - refute String.contains?(message, "Displays this help text.") - end - - test "help whois", %{socket: socket} do - message_coordinator(socket, "$help whois") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - assert String.contains?(message, "$whois ") - assert String.contains?(message, "Sends back information about the user specified.") - refute String.contains?(message, "Displays this help text.") - end - - test "help pull", %{socket: socket, user: user} do - # Normal pull test - message_coordinator(socket, "$help pull") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - - assert message == "No commands matching that filter." - refute String.contains?(message, "Pulls a given user into the battle.") - refute String.contains?(message, "Displays this help text.") - - # Moderator pull test - CacheUser.update_user(%{user | moderator: true}) - message_coordinator(socket, "$help pull") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - message = reply["message"] - - refute message == "No commands matching that filter." - assert String.contains?(message, "Pulls a given user into the battle.") - refute String.contains?(message, "Displays this help text.") - end - - test "whoami", %{socket: socket, user: user, coordinator_userid: coordinator_userid} do - message_coordinator(socket, "$whoami") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - String.trim(""" - --------------------------- - You are #{user.name} - Playtime: 0 hours (0 h playing, 0 h spectating) - Profile link: https://localhost/teiserver/profile/#{user.id} - Skill ratings: - You currently have no accolades - """), - "sender_id" => coordinator_userid - } - end - - test "whois", %{socket: socket, coordinator_userid: coordinator_userid} do - other_user = new_user() - - message_coordinator(socket, "$whois #{other_user.name}") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - String.trim(""" - --------------------------- - Found #{other_user.name} - Profile link: https://localhost/teiserver/profile/#{other_user.id} - Ratings: - No moderation restrictions applied. - --------------------------- - """), - "sender_id" => coordinator_userid - } - - # Now with previous names - Account.update_user_stat(other_user.id, %{ - "previous_names" => ["name1", "name2"] - }) - - message_coordinator(socket, "$whois #{other_user.name}") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - String.trim(""" - --------------------------- - Found #{other_user.name} - Previous names: name1, name2 - Profile link: https://localhost/teiserver/profile/#{other_user.id} - Ratings: - No moderation restrictions applied. - --------------------------- - """), - "sender_id" => coordinator_userid - } - end - - test "mute user command", %{socket: socket, user: user, coordinator_userid: coordinator_userid} do - %{user: user2} = tachyon_auth_setup() - - message_coordinator(socket, "$mute #{user2.name}") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - "#{user2.name} is now ignored, you can unmute them with the $unignore command or via the account section of the server website.", - "sender_id" => coordinator_userid - } - - user = CacheUser.get_user_by_id(user.id) - assert user.ignored == [user2.id] - - # Now use it again, make sure we don't get a crash - message_coordinator(socket, "$unmute #{user2.name}") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => "#{user2.name} is now un-ignored.", - "sender_id" => coordinator_userid - } - - user = CacheUser.get_user_by_id(user.id) - assert user.ignored == [] - - # Now unmute again - message_coordinator(socket, "$unmute #{user2.name}") - [reply] = _tachyon_recv(socket) - assert reply == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [reply] = _tachyon_recv(socket) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => "#{user2.name} is now un-ignored.", - "sender_id" => coordinator_userid - } - - user = CacheUser.get_user_by_id(user.id) - assert user.ignored == [] - end - - defp message_coordinator(socket, message) do - _tachyon_send(socket, %{ - cmd: "c.communication.send_direct_message", - message: message, - recipient_id: Coordinator.get_coordinator_userid() - }) - end -end diff --git a/test/teiserver/coordinator/gatekeeper_test.exs b/test/teiserver/coordinator/gatekeeper_test.exs deleted file mode 100644 index df1551218..000000000 --- a/test/teiserver/coordinator/gatekeeper_test.exs +++ /dev/null @@ -1,137 +0,0 @@ -defmodule Teiserver.Coordinator.GatekeeperTest do - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.Account.UserCacheLib - alias Teiserver.{Client, Coordinator, Lobby} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - UserCacheLib.update_user(%{host | moderator: true}) - ClientLib.refresh_client(host.id) - - battle_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: battle_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.force_add_user_to_lobby(player.id, lobby_id) - :timer.sleep(100) - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv(hsocket) - - # Battlestatus message - _tachyon_recv(hsocket) - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - test "friendsplay", %{player: player, hsocket: hsocket, psocket: psocket, lobby_id: lobby_id} do - player_client = Client.get_client_by_id(player.id) - assert player_client.player == true - assert player_client.lobby_id == lobby_id - - # Whitelist them to spectator but defaults to player - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$gatekeeper friendsplay"}) - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$forcespec ##{player.id}"}) - - # Check state - gatekeeper = Coordinator.call_consul(lobby_id, {:get, :gatekeeper}) - assert gatekeeper == :friendsplay - - # Check it's worked - player_client = Client.get_client_by_id(player.id) - assert player_client.player == false - assert player_client.lobby_id == lobby_id - - # Try to change it - data = %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}} - _tachyon_send(psocket, data) - - # No players, we should be able to become a player even though having no "friends" in the game - player_client = Client.get_client_by_id(player.id) - assert player_client.player == true - assert player_client.lobby_id == lobby_id - - # Now for player 2 - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$gatekeeper friendsplay"}) - - # Now we bring in player 2, they should be allowed in - %{user: player2, socket: psocket2} = tachyon_auth_setup() - assert match?({:waiting_on_host, _}, Lobby.can_join?(player2.id, lobby_id)) - - # Okay, add them - Lobby.force_add_user_to_lobby(player2.id, lobby_id) - data = %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}} - _tachyon_send(psocket2, data) - - player_client2 = Client.get_client_by_id(player2.id) - assert player_client2.player == false - assert player_client2.lobby_id == lobby_id - end - - test "friends", %{player: player, psocket: psocket, hsocket: hsocket, lobby_id: lobby_id} do - player_client = Client.get_client_by_id(player.id) - assert player_client.player == true - assert player_client.lobby_id == lobby_id - - # Whitelist them to spectator but defaults to player - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$gatekeeper friends"}) - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$forcespec ##{player.id}"}) - - # Check state - gatekeeper = Coordinator.call_consul(lobby_id, {:get, :gatekeeper}) - assert gatekeeper == :friends - - # They should still be here - player_client = Client.get_client_by_id(player.id) - assert player_client.player == false - assert player_client.lobby_id == lobby_id - - # Try to change it - data = %{cmd: "c.lobby.update_status", client: %{player: true, ready: true}} - _tachyon_send(psocket, data) - - # Change should be fine - player_client = Client.get_client_by_id(player.id) - assert player_client.player == true - assert player_client.lobby_id == lobby_id - - # Now we bring in player 2, they should not be allowed in - %{user: player2} = tachyon_auth_setup() - # assert Lobby.can_join?(player2.id, lobby_id) == {:waiting_on_host, nil} - assert match?({:waiting_on_host, _}, Lobby.can_join?(player2.id, lobby_id)) - end -end diff --git a/test/teiserver/coordinator/host_update_test.exs b/test/teiserver/coordinator/host_update_test.exs deleted file mode 100644 index 37a5bf521..000000000 --- a/test/teiserver/coordinator/host_update_test.exs +++ /dev/null @@ -1,85 +0,0 @@ -defmodule Teiserver.Coordinator.HostUpdateTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{Lobby, Client, Coordinator} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - battle_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: battle_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.force_add_user_to_lobby(player.id, lobby_id) - :timer.sleep(100) - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true, ready: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv(hsocket) - - # Battlestatus message - _tachyon_recv(hsocket) - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - test "Update host data teamSize/teamCount", %{ - hsocket: hsocket, - psocket: psocket, - lobby_id: lobby_id - } do - # Host can change teamSize - data = %{cmd: "c.lobby.message", message: "Global setting changed by marseel (teamSize=7)"} - _tachyon_send(hsocket, data) - teamSize = Coordinator.call_consul(lobby_id, {:get, :host_teamsize}) - assert teamSize == 7 - - # Player cannot change teamSize - data = %{cmd: "c.lobby.message", message: "Global setting changed by marseel (teamSize=3)"} - _tachyon_send(psocket, data) - teamSize = Coordinator.call_consul(lobby_id, {:get, :host_teamsize}) - # Assert not changed - assert teamSize == 7 - - # Host can change teamCount - data = %{cmd: "c.lobby.message", message: "Global setting changed by marseel (nbTeams=4)"} - _tachyon_send(hsocket, data) - teamSize = Coordinator.call_consul(lobby_id, {:get, :host_teamcount}) - assert teamSize == 4 - - # Player cannot change teamCount - data = %{cmd: "c.lobby.message", message: "Global setting changed by marseel (nbTeams=2)"} - _tachyon_send(psocket, data) - teamSize = Coordinator.call_consul(lobby_id, {:get, :host_teamcount}) - assert teamSize == 4 - end -end diff --git a/test/teiserver/coordinator/joining_test.exs b/test/teiserver/coordinator/joining_test.exs deleted file mode 100644 index 81f8dcf12..000000000 --- a/test/teiserver/coordinator/joining_test.exs +++ /dev/null @@ -1,151 +0,0 @@ -defmodule Teiserver.Coordinator.JoiningTest do - use Teiserver.ServerCase, async: false - alias Teiserver.Common.PubsubListener - alias Teiserver.Account.ClientLib - alias Teiserver.Coordinator - - alias Teiserver.Account.UserCacheLib - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: socket, user: user} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - UserCacheLib.update_user(%{user | moderator: true}) - ClientLib.refresh_client(user.id) - - battle_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: battle_data} - _tachyon_send(socket, data) - [reply] = _tachyon_recv(socket) - lobby_id = reply["lobby"]["id"] - - listener = PubsubListener.new_listener(["teiserver_lobby_chat:#{lobby_id}"]) - - {:ok, socket: socket, user: user, lobby_id: lobby_id, listener: listener} - end - - test "welcome message", %{socket: socket, user: user, lobby_id: lobby_id, listener: listener} do - consul_state = Coordinator.call_consul(lobby_id, :get_all) - assert consul_state.welcome_message == nil - - data = %{cmd: "c.lobby.message", message: "$welcome-message This is the welcome message"} - _tachyon_send(socket, data) - - messages = PubsubListener.get(listener) - - assert messages == [ - %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :announce, - lobby_id: lobby_id, - message: "New welcome message set to: This is the welcome message", - userid: Coordinator.get_coordinator_userid() - }, - %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :say, - lobby_id: lobby_id, - message: "$welcome-message This is the welcome message", - userid: user.id - } - ] - - consul_state = Coordinator.call_consul(lobby_id, :get_all) - assert consul_state.welcome_message == "This is the welcome message" - - # Now a new user joins the battle - %{socket: socket2, user: user2} = tachyon_auth_setup() - data = %{cmd: "c.lobby.join", lobby_id: lobby_id} - _tachyon_send(socket2, data) - - [reply] = _tachyon_recv(socket2) - - assert reply == %{ - "cmd" => "s.lobby.join", - "result" => "waiting_for_host" - } - - # Accept them - data = %{cmd: "c.lobby_host.respond_to_join_request", userid: user2.id, response: "approve"} - - _tachyon_send(socket, data) - [join_response] = _tachyon_recv(socket2) - assert join_response["cmd"] == "s.lobby.joined" - assert join_response["lobby"]["id"] == lobby_id - - # Expect welcome message - [reply] = _tachyon_recv(socket2) - - assert reply == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - "########################################\nThis is the welcome message\n########################################", - "sender_id" => Coordinator.get_coordinator_userid() - } - - # Send the battle status - data = %{ - cmd: "c.lobby.update_status", - client: %{ - player: true, - sync: 1, - player_number: 0, - team_number: 0, - side: 0, - team_colour: "0", - ready: true - } - } - - _tachyon_send(socket2, data) - - # We expect to hear about our new status - [reply] = _tachyon_recv(socket2) - - assert reply == %{ - "cmd" => "s.lobby.updated_client_battlestatus", - "client" => %{ - "team_number" => 0, - "away" => false, - "in_game" => false, - "lobby_id" => lobby_id, - "ready" => false, - "team_colour" => "0", - "player_number" => 0, - "userid" => user2.id, - "player" => true, - "sync" => ["game", "map"], - "clan_tag" => nil, - "muted" => false, - "party_id" => nil - }, - "lobby_id" => lobby_id, - "reason" => "client_updated_battlestatus" - } - - # No more messages - reply = _tachyon_recv(socket2) - assert reply == :timeout - end -end diff --git a/test/teiserver/coordinator/lock_test.exs b/test/teiserver/coordinator/lock_test.exs deleted file mode 100644 index 66eac2283..000000000 --- a/test/teiserver/coordinator/lock_test.exs +++ /dev/null @@ -1,188 +0,0 @@ -defmodule Teiserver.Coordinator.LockTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{Client, Coordinator, Lobby} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - battle_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: battle_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.force_add_user_to_lobby(player.id, lobby_id) - :timer.sleep(100) - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true, ready: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv(hsocket) - - # Battlestatus message - _tachyon_recv(hsocket) - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - test "lock and unlock", %{hsocket: hsocket, lobby_id: lobby_id} do - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [] - - # Add a lock - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock team"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:team] - - # Add another lock - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock allyid"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid, :team] - - # Add a duplicate lock - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock allyid"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid, :team] - - # Remove a lock - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock team"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid] - - # Add a lock that doesn't exist - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock ptaq"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid] - - # Remove a lock not in there - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock team"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid] - - # Remove a lock that doesn't exist - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock damgam"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid] - - # Lock nothing - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid] - - # Unlock nothing - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock"}) - locks = Coordinator.call_consul(lobby_id, {:get, :locks}) - assert locks == [:allyid] - end - - test "team_number", %{player: player, hsocket: hsocket, psocket: psocket, lobby_id: lobby_id} do - # Try to change team - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{team_number: 1}}) - assert Client.get_client_by_id(player.id).team_number == 1 - - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{team_number: 2}}) - assert Client.get_client_by_id(player.id).team_number == 2 - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock team"}) - assert Coordinator.call_consul(lobby_id, {:get, :locks}) == [:team] - - # Lock team and try to change it - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{team_number: 1}}) - assert Client.get_client_by_id(player.id).team_number == 2 - - # Unlock and change - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock team"}) - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{team_number: 1}}) - assert Client.get_client_by_id(player.id).team_number == 1 - end - - test "player_number", %{player: player, hsocket: hsocket, psocket: psocket, lobby_id: lobby_id} do - # Try to change team - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player_number: 1}}) - assert Client.get_client_by_id(player.id).player_number == 1 - - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player_number: 2}}) - assert Client.get_client_by_id(player.id).player_number == 2 - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock allyid"}) - assert Coordinator.call_consul(lobby_id, {:get, :locks}) == [:allyid] - - # Lock team and try to change it - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player_number: 1}}) - assert Client.get_client_by_id(player.id).player_number == 2 - - # Unlock and change - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock allyid"}) - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player_number: 1}}) - assert Client.get_client_by_id(player.id).player_number == 1 - end - - test "player", %{player: player, hsocket: hsocket, psocket: psocket, lobby_id: lobby_id} do - # Try to change team - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: true}}) - assert Client.get_client_by_id(player.id).player == true - - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: false}}) - assert Client.get_client_by_id(player.id).player == false - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock player"}) - assert Coordinator.call_consul(lobby_id, {:get, :locks}) == [:player] - - # Lock team and try to change it - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: true}}) - assert Client.get_client_by_id(player.id).player == false - - # Unlock and change - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock player"}) - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: true}}) - assert Client.get_client_by_id(player.id).player == true - end - - test "spectator", %{player: player, hsocket: hsocket, psocket: psocket, lobby_id: lobby_id} do - # Try to change team - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: false}}) - assert Client.get_client_by_id(player.id).player == false - - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: true}}) - assert Client.get_client_by_id(player.id).player == true - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$lock spectator"}) - assert Coordinator.call_consul(lobby_id, {:get, :locks}) == [:spectator] - - # Lock team and try to change it - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: false}}) - assert Client.get_client_by_id(player.id).player == true - - # Unlock and change - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$unlock spectator"}) - _tachyon_send(psocket, %{cmd: "c.lobby.update_status", client: %{player: false}}) - assert Client.get_client_by_id(player.id).player == false - end -end diff --git a/test/teiserver/coordinator/match_monitor_server_test.exs b/test/teiserver/coordinator/match_monitor_server_test.exs deleted file mode 100644 index 35f14603a..000000000 --- a/test/teiserver/coordinator/match_monitor_server_test.exs +++ /dev/null @@ -1,136 +0,0 @@ -defmodule Teiserver.Coordinator.MatchMonitorServerTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{CacheUser, Chat, Client, Lobby} - alias Teiserver.Coordinator.{CoordinatorServer} - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - account = CoordinatorServer.get_coordinator_account() - Teiserver.cache_put(:application_metadata_cache, "teiserver_coordinator_userid", account.id) - - Teiserver.Battle.start_match_monitor() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - CacheUser.update_user(%{host | bot: true}) - - battle_data = %{ - cmd: "c.lobby.create", - name: "MonitorMatch #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: battle_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.force_add_user_to_lobby(player.id, lobby_id) - :timer.sleep(100) - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true, ready: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv(hsocket) - - # Battlestatus message - _tachyon_recv(hsocket) - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - @tag :needs_attention - test "chat messages", %{hsocket: hsocket, host: host, player: player} do - monitor_user = CacheUser.get_user_by_name("AutohostMonitor") - messages1 = Chat.list_lobby_messages(search: [user_id: host.id]) - messages2 = Chat.list_lobby_messages(search: [user_id: player.id]) - - assert Enum.empty?(messages1) - assert Enum.empty?(messages2) - - _tachyon_send(hsocket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => monitor_user.id, - "message" => "match-chat <#{player.name}> dallies: Allied chat message" - }) - - :timer.sleep(100) - - messages1 = Chat.list_lobby_messages(search: [user_id: host.id]) - messages2 = Chat.list_lobby_messages(search: [user_id: player.id]) - - assert Enum.empty?(messages1) - assert Enum.count(messages2) == 1 - - _tachyon_send(hsocket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => monitor_user.id, - "message" => "match-chat <#{player.name}> d: Game chat message" - }) - - :timer.sleep(100) - - messages1 = Chat.list_lobby_messages(search: [user_id: host.id]) - messages2 = Chat.list_lobby_messages(search: [user_id: player.id]) - - assert Enum.empty?(messages1) - assert Enum.count(messages2) == 1 - - _tachyon_send(hsocket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => monitor_user.id, - "message" => "match-chat <#{player.name}> dspectators: Spec chat message" - }) - - :timer.sleep(100) - - messages1 = Chat.list_lobby_messages(search: [user_id: host.id]) - messages2 = Chat.list_lobby_messages(search: [user_id: player.id]) - - assert Enum.empty?(messages1) - assert Enum.count(messages2) == 2 - - [allied, spectator] = messages2 - - assert match?( - %{ - content: "a: Allied chat message" - }, - allied - ) - - # assert match?(%{ - # content: "g: Game chat message" - # }, game) - assert match?( - %{ - content: "s: Spec chat message" - }, - spectator - ) - - # _tachyon_send(hsocket, %{ - # "cmd" => "c.communication.send_direct_message", - # "recipient_id" => monitor_user.id, - # "message" => "match-chat <#{player.name}> d123: Direct chat message" - # }) - end -end diff --git a/test/teiserver/coordinator/memes_test.exs b/test/teiserver/coordinator/memes_test.exs deleted file mode 100644 index dbdc570b9..000000000 --- a/test/teiserver/coordinator/memes_test.exs +++ /dev/null @@ -1,170 +0,0 @@ -defmodule Teiserver.Coordinator.MemesTest do - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.{CacheUser, Client, Coordinator, Lobby} - require Logger - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1, _tachyon_recv_until: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - CacheUser.update_user(%{host | moderator: true}) - ClientLib.refresh_client(host.id) - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.add_user_to_battle(player.id, lobby_id, "script_password") - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv_until(hsocket) - - # Battlestatus message - _tachyon_recv_until(hsocket) - - {:ok, hsocket: hsocket, psocket: psocket, host: host, player: player, lobby_id: lobby_id} - end - - test "non-meme", %{hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme not_a_meme"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.received_lobby_direct_announce", - "message" => - "That's not a valid meme. The memes are ticks, nodefence, greenfields, poor, rich, hardt1, crazy, undo", - "sender_id" => Coordinator.get_coordinator_userid() - } - end - - test "ticks", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme ticks"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => %{ - "disabled_units" => - ~w(armaap armalab armap armavp armhp armshltx armvp armamsub armasy armfhp armplat armshltxuw armsy armmg armllt armbeamer armhlt arm armdrag armclaw armguard armjuno armham armjeth armpw armrectr armrock armwar coraap coralab corap coravp corgant corhp corlab corvp corllt corfhp corsy corjuno corhllt corhlt) - } - } - end - - test "greenfields", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme greenfields"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => %{ - "disabled_units" => ~w(armmex armamex armmoho cormex corexp cormexp cormoho) - } - } - end - - test "poor", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme poor"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.set_modoptions", - "lobby_id" => lobby_id, - "new_options" => %{ - "game/modoptions/multiplier_resourceincome" => "0" - } - } - end - - test "rich", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme rich"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.set_modoptions", - "lobby_id" => lobby_id, - "new_options" => %{ - "game/modoptions/multiplier_resourceincome" => "1000", - "game/modoptions/startenergy" => "100000000", - "game/modoptions/startmetal" => "100000000" - } - } - end - - test "hardt1", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme hardt1"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => %{ - "disabled_units" => - ~w(armfhp armhp armamsub armplat armalab armavp armaap armasy armshltx armshltxuw corfhp corhp coaramsub corplat coravp coralab coraap corgantuw corgant corasy) - } - } - end - - test "crazy", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme crazy"}) - [reply] = _tachyon_recv(hsocket) - assert reply["cmd"] == "s.lobby.set_modoptions" - assert reply["lobby_id"] == lobby_id - end - - test "undo", %{lobby_id: lobby_id, hsocket: hsocket} do - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme ticks"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => %{ - "disabled_units" => - ~w(armaap armalab armap armavp armhp armshltx armvp armamsub armasy armfhp armplat armshltxuw armsy armmg armllt armbeamer armhlt arm armdrag armclaw armguard armjuno armham armjeth armpw armrectr armrock armwar coraap coralab corap coravp corgant corhp corlab corvp corllt corfhp corsy corjuno corhllt corhlt) - } - } - - _tachyon_send(hsocket, %{cmd: "c.lobby.message", message: "$meme undo"}) - [reply] = _tachyon_recv(hsocket) - - assert reply == %{ - "cmd" => "s.lobby.update_values", - "lobby_id" => lobby_id, - "new_values" => %{"disabled_units" => []} - } - end -end diff --git a/test/teiserver/coordinator/moderation_test.exs b/test/teiserver/coordinator/moderation_test.exs deleted file mode 100644 index 9778fc40d..000000000 --- a/test/teiserver/coordinator/moderation_test.exs +++ /dev/null @@ -1,106 +0,0 @@ -defmodule Teiserver.Coordinator.ModerationTest do - use Teiserver.ServerCase, async: false - alias Teiserver.{CacheUser, Coordinator, Client, Moderation} - import Teiserver.Helper.TimexHelper, only: [date_to_str: 2] - alias Teiserver.Moderation.RefreshUserRestrictionsTask - - import Teiserver.TeiserverTestLib, - only: [new_user: 0, tachyon_auth_setup: 1, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - user = new_user() - {:ok, user: user} - end - - @tag :needs_attention - test "login with warning", %{user: user} do - delay = Teiserver.Config.get_site_config_cache("teiserver.Post login action delay") - - refute CacheUser.has_warning?(user.id) - refute CacheUser.has_mute?(user.id) - refute CacheUser.is_restricted?(user.id, ["Login"]) - - {:ok, action} = - Moderation.create_action(%{ - "reason" => "login_with_warning_test", - "target_id" => user.id, - "restrictions" => ["Warning reminder"], - "score_modifier" => 0, - "expires" => Timex.now() |> Timex.shift(days: 1) - }) - - # User.new_moderation_action(action) - RefreshUserRestrictionsTask.refresh_user(user.id) - - # Did it take? - assert CacheUser.has_warning?(user.id) - refute CacheUser.has_mute?(user.id) - refute CacheUser.is_restricted?(user.id, ["Login"]) - - # Now login - %{socket: socket} = tachyon_auth_setup(user) - :timer.sleep(200 + delay) - - expires = date_to_str(action.expires, format: :ymd_hms) - [msg] = _tachyon_recv(socket) - - assert msg == %{ - "cmd" => "s.communication.received_direct_message", - "message" => - String.trim(""" - This is a reminder that you received one or more formal moderation actions as listed below: - - login_with_warning_test, expires #{expires} - If you feel you have been the target of an erroneous or unjust moderation action please use the #open-ticket channel in our discord to appeal/dispute the action. - Acknowledge this by typing 'I acknowledge this' to resume play - """), - "sender_id" => Coordinator.get_coordinator_userid() - } - - client = Client.get_client_by_id(user.id) - assert client.awaiting_warn_ack - - # Send something back - _tachyon_send(socket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => Coordinator.get_coordinator_userid(), - "message" => "Nope nope nope" - }) - - :timer.sleep(200) - [msg] = _tachyon_recv(socket) - assert msg == %{"cmd" => "s.communication.send_direct_message", "result" => "success"} - - [msg] = _tachyon_recv(socket) - - assert msg == %{ - "cmd" => "s.communication.received_direct_message", - "message" => "I don't currently handle messages, sorry #{user.name}", - "sender_id" => Coordinator.get_coordinator_userid() - } - - client = Client.get_client_by_id(user.id) - assert client.awaiting_warn_ack - - # Now send back the correct response - _tachyon_send(socket, %{ - "cmd" => "c.communication.send_direct_message", - "recipient_id" => Coordinator.get_coordinator_userid(), - "message" => "I acknowledge this" - }) - - _ = _tachyon_recv(socket) - [msg] = _tachyon_recv(socket) - - assert msg == %{ - "cmd" => "s.communication.received_direct_message", - "message" => "Thank you", - "sender_id" => Coordinator.get_coordinator_userid() - } - - client = Client.get_client_by_id(user.id) - refute client.awaiting_warn_ack - end -end diff --git a/test/teiserver/coordinator/setup_test.exs b/test/teiserver/coordinator/setup_test.exs deleted file mode 100644 index d72bb70ca..000000000 --- a/test/teiserver/coordinator/setup_test.exs +++ /dev/null @@ -1,72 +0,0 @@ -defmodule Teiserver.Protocols.Coordinator.SetupTest do - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.Account.UserCacheLib - alias Teiserver.TeiserverTestLib - alias Teiserver.{Battle, Lobby} - alias Teiserver.Common.PubsubListener - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_recv: 1] - - @sleep 50 - @moduletag :needs_attention - - setup do - %{socket: socket, user: user, pid: pid} = tachyon_auth_setup() - - UserCacheLib.update_user(%{user | moderator: true}) - ClientLib.refresh_client(user.id) - - {:ok, socket: socket, user: user, pid: pid} - end - - test "test command vs no command", %{user: user, socket: socket} do - lobby = - TeiserverTestLib.make_battle(%{ - founder_id: user.id, - founder_name: user.name - }) - - lobby = Battle.get_lobby(lobby.id) - listener = PubsubListener.new_listener(["teiserver_lobby_chat:#{lobby.id}"]) - - # No command - result = Lobby.say(user.id, "Test message", lobby.id) - assert result == :ok - - :timer.sleep(@sleep) - messages = PubsubListener.get(listener) - - assert messages == [ - %{ - channel: "teiserver_lobby_chat:#{lobby.id}", - event: :say, - lobby_id: lobby.id, - message: "Test message", - userid: user.id - } - ] - - # Now command - result = Lobby.say(user.id, "$settag tagname tagvalue", lobby.id) - assert result == :ok - - :timer.sleep(@sleep) - reply = _tachyon_recv(socket) - assert reply == :timeout - - # Converted message should appear here - messages = PubsubListener.get(listener) - - assert messages == [ - %{ - channel: "teiserver_lobby_chat:#{lobby.id}", - event: :say, - lobby_id: lobby.id, - message: "$settag tagname tagvalue", - userid: user.id - } - ] - end -end diff --git a/test/teiserver/coordinator/split_test.exs b/test/teiserver/coordinator/split_test.exs deleted file mode 100644 index 0a8fbb790..000000000 --- a/test/teiserver/coordinator/split_test.exs +++ /dev/null @@ -1,580 +0,0 @@ -defmodule Teiserver.Coordinator.SplitTest do - use Teiserver.ServerCase, async: false - alias Teiserver.Account.ClientLib - alias Teiserver.Common.PubsubListener - alias Teiserver.{CacheUser, Client, Coordinator, Lobby} - alias Teiserver.Coordinator.CoordinatorLib - - import Teiserver.TeiserverTestLib, - only: [tachyon_auth_setup: 0, _tachyon_send: 2, _tachyon_recv: 1] - - @moduletag :needs_attention - - setup do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - %{socket: hsocket_empty} = tachyon_auth_setup() - %{socket: psocket, user: player} = tachyon_auth_setup() - - CacheUser.update_user(%{host | moderator: true}) - CacheUser.update_user(%{player | moderator: true}) - ClientLib.refresh_client(host.id) - ClientLib.refresh_client(player.id) - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket, data) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - listener = PubsubListener.new_listener(["teiserver_lobby_chat:#{lobby_id}"]) - - # Create an empty battle for them - lobby_data = %{ - cmd: "c.lobby.create", - name: "Empty battle - #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "empty valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 12 - } - } - - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket_empty, data) - [reply] = _tachyon_recv(hsocket_empty) - empty_lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - Lobby.add_user_to_battle(player.id, lobby_id, "script_password") - player_client = Client.get_client_by_id(player.id) - - Client.update( - %{player_client | player: true}, - :client_updated_battlestatus - ) - - # Add user message - _tachyon_recv(hsocket) - - # Battlestatus message - _tachyon_recv(hsocket) - - {:ok, - hsocket: hsocket, - psocket: psocket, - host: host, - player: player, - lobby_id: lobby_id, - listener: listener, - empty_lobby_id: empty_lobby_id} - end - - test "basic split test", %{ - host: _host, - player: player1, - psocket: psocket1, - lobby_id: lobby_id, - listener: listener, - empty_lobby_id: empty_lobby_id - } do - %{user: player2, socket: psocket2} = tachyon_auth_setup() - %{user: player3, socket: psocket3} = tachyon_auth_setup() - %{user: player4, socket: psocket4} = tachyon_auth_setup() - %{user: player5, socket: psocket5} = tachyon_auth_setup() - %{user: player6, socket: psocket6} = tachyon_auth_setup() - - # Add players to the lobby - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player3.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player4.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player5.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player6.id, lobby_id, "script_password") - - # Normally the player joins through the standard means but we're doing a test so it's a bit janky atm - send(Client.get_client_by_id(player1.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player2.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player3.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player4.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player5.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player6.id).tcp_pid, {:put, :lobby_id, lobby_id}) - - data = %{cmd: "c.lobby.message", message: "$splitlobby"} - _tachyon_send(psocket1, data) - - # Check what got sent - messages = PubsubListener.get(listener) - - assert Enum.member?(messages, %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :announce, - lobby_id: lobby_id, - message: - "Split lobby sequence started ($y to move, $n to cancel, $follow to follow user)", - userid: Coordinator.get_coordinator_userid() - }), - message: inspect(messages) - - assert Enum.member?(messages, %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :say, - lobby_id: lobby_id, - message: "$splitlobby", - userid: player1.id - }), - message: inspect(messages) - - # Check state - split = Coordinator.call_consul(lobby_id, {:get, :split}) - assert split.first_splitter_id == player1.id - assert split.splitters == %{} - - # Now they can say what they want to do! - # 1 will say yes then no, they are the splitter so should have no impact - # 2 will say yes - # 3 will say yes then change their mind and say no - # 4 will follow 2 - # 5 will follow 4 (and thus follow 2) - # 6 will follow 1 (which should be translated to a yes) - # End result should be 1, 2, 4, 5 move to a new lobby - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket2, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket3, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket4, %{cmd: "c.lobby.message", message: "$follow #{player2.name}"}) - _tachyon_send(psocket5, %{cmd: "c.lobby.message", message: "$follow #{player4.name}"}) - _tachyon_send(psocket6, %{cmd: "c.lobby.message", message: "$follow #{player1.name}"}) - :timer.sleep(200) - - # Check state - split = Coordinator.call_consul(lobby_id, {:get, :split}) - assert split.first_splitter_id == player1.id - - assert split.splitters == %{ - player1.id => true, - player2.id => true, - player3.id => true, - player4.id => player2.id, - player5.id => player4.id, - player6.id => true - } - - # Now update choices - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$n"}) - _tachyon_send(psocket3, %{cmd: "c.lobby.message", message: "$n"}) - - split = Coordinator.call_consul(lobby_id, {:get, :split}) - assert split.first_splitter_id == player1.id - - assert split.splitters == %{ - player2.id => true, - player4.id => player2.id, - player5.id => player4.id, - player6.id => true - } - - # Time to resolve - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$dosplit"}) - :timer.sleep(200) - - assert Client.get_client_by_id(player1.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player2.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player3.id).lobby_id == lobby_id - assert Client.get_client_by_id(player4.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player5.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player6.id).lobby_id == empty_lobby_id - end - - test "test split with different engine version", %{ - host: _host, - player: player1, - psocket: psocket1, - lobby_id: lobby_id, - listener: listener, - empty_lobby_id: empty_lobby_id - } do - %{user: player2, socket: psocket2} = tachyon_auth_setup() - %{user: player3, socket: psocket3} = tachyon_auth_setup() - %{user: player4, socket: _psocket4} = tachyon_auth_setup() - %{user: player5, socket: _psocket5} = tachyon_auth_setup() - %{user: player6, socket: _psocket6} = tachyon_auth_setup() - - # Add players to the lobby - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player3.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player4.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player5.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player6.id, lobby_id, "script_password") - - # Normally the player joins through the standard means but we're doing a test so it's a bit janky atm - send(Client.get_client_by_id(player1.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player2.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player3.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player4.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player5.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player6.id).tcp_pid, {:put, :lobby_id, lobby_id}) - - # Remove empty lobby with matching engine version - Lobby.close_lobby(empty_lobby_id) - - # Add an empty lobby but with a different engine version - lobby_data = %{ - cmd: "c.lobby.create", - name: "Empty battle - #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "empty valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "lex.1.2.3", - settings: %{ - max_players: 12 - } - } - - %{socket: hsocket_empty} = tachyon_auth_setup() - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket_empty, data) - [reply] = _tachyon_recv(hsocket_empty) - _empty_lobby_id = reply["lobby"]["id"] - - data = %{cmd: "c.lobby.message", message: "$splitlobby"} - _tachyon_send(psocket1, data) - - # Check what got sent - messages = PubsubListener.get(listener) - - assert Enum.member?(messages, %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :announce, - lobby_id: lobby_id, - message: - "Split lobby sequence started ($y to move, $n to cancel, $follow to follow user)", - userid: Coordinator.get_coordinator_userid() - }), - message: inspect(messages) - - assert Enum.member?(messages, %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :say, - lobby_id: lobby_id, - message: "$splitlobby", - userid: player1.id - }), - message: inspect(messages) - - # Check state - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket2, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket3, %{cmd: "c.lobby.message", message: "$y"}) - :timer.sleep(200) - - # Time to resolve - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$dosplit"}) - :timer.sleep(200) - - # Split should fail because there are no empty lobbies with the same engine version as the starting one - assert Client.get_client_by_id(player1.id).lobby_id == lobby_id - assert Client.get_client_by_id(player2.id).lobby_id == lobby_id - assert Client.get_client_by_id(player3.id).lobby_id == lobby_id - assert Client.get_client_by_id(player4.id).lobby_id == lobby_id - assert Client.get_client_by_id(player5.id).lobby_id == lobby_id - assert Client.get_client_by_id(player6.id).lobby_id == lobby_id - end - - test "test split with passworded lobby", %{ - host: _host, - player: player1, - psocket: psocket1, - lobby_id: lobby_id, - listener: listener, - empty_lobby_id: empty_lobby_id - } do - %{user: player2, socket: psocket2} = tachyon_auth_setup() - %{user: player3, socket: psocket3} = tachyon_auth_setup() - %{user: player4, socket: _psocket4} = tachyon_auth_setup() - %{user: player5, socket: _psocket5} = tachyon_auth_setup() - %{user: player6, socket: _psocket6} = tachyon_auth_setup() - - # Add players to the lobby - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player3.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player4.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player5.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player6.id, lobby_id, "script_password") - - # Normally the player joins through the standard means but we're doing a test so it's a bit janky atm - send(Client.get_client_by_id(player1.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player2.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player3.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player4.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player5.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player6.id).tcp_pid, {:put, :lobby_id, lobby_id}) - - # Remove empty lobby with matching engine version - Lobby.close_lobby(empty_lobby_id) - - # Add an empty passworded lobby - lobby_data = %{ - cmd: "c.lobby.create", - name: "Empty battle - #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "empty valley", - game_name: "BAR", - passworded: true, - settings: %{ - max_players: 12 - } - } - - %{socket: hsocket_empty} = tachyon_auth_setup() - data = %{cmd: "c.lobby.create", lobby: lobby_data} - _tachyon_send(hsocket_empty, data) - [reply] = _tachyon_recv(hsocket_empty) - _empty_lobby_id = reply["lobby"]["id"] - - data = %{cmd: "c.lobby.message", message: "$splitlobby"} - _tachyon_send(psocket1, data) - - # Check what got sent - messages = PubsubListener.get(listener) - - assert Enum.member?(messages, %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :announce, - lobby_id: lobby_id, - message: - "Split lobby sequence started ($y to move, $n to cancel, $follow to follow user)", - userid: Coordinator.get_coordinator_userid() - }), - message: inspect(messages) - - assert Enum.member?(messages, %{ - channel: "teiserver_lobby_chat:#{lobby_id}", - event: :say, - lobby_id: lobby_id, - message: "$splitlobby", - userid: player1.id - }), - message: inspect(messages) - - # Check state - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket2, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket3, %{cmd: "c.lobby.message", message: "$y"}) - :timer.sleep(200) - - # Time to resolve - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$dosplit"}) - :timer.sleep(200) - - # Split should fail because there are no empty lobbies without passwords - assert Client.get_client_by_id(player1.id).lobby_id == lobby_id - assert Client.get_client_by_id(player2.id).lobby_id == lobby_id - assert Client.get_client_by_id(player3.id).lobby_id == lobby_id - assert Client.get_client_by_id(player4.id).lobby_id == lobby_id - assert Client.get_client_by_id(player5.id).lobby_id == lobby_id - assert Client.get_client_by_id(player6.id).lobby_id == lobby_id - end - - test "test split resolving" do - # Basic test - result = - CoordinatorLib.resolve_split(%{ - 1 => true, - 2 => true - }) - - assert result == %{ - 1 => true, - 2 => true - } - - # Add a nil entry - result = - CoordinatorLib.resolve_split(%{ - 1 => true, - 2 => true, - 3 => nil - }) - - assert result == %{ - 1 => true, - 2 => true - } - - # Swap it for a false, just to see - result = - CoordinatorLib.resolve_split(%{ - 1 => true, - 2 => true, - 3 => false - }) - - assert result == %{ - 1 => true, - 2 => true - } - - # Add a follow - result = - CoordinatorLib.resolve_split(%{ - 1 => true, - 2 => true, - 3 => nil, - 4 => 1 - }) - - assert result == %{ - 1 => true, - 2 => true, - 4 => true - } - - # Add a follow of a follow and a negative follow - result = - CoordinatorLib.resolve_split(%{ - 1 => true, - 2 => true, - 3 => nil, - 4 => 1, - 5 => 4, - 6 => 3 - }) - - assert result == %{ - 1 => true, - 2 => true, - 4 => true, - 5 => true - } - - # Endless loop - result = - CoordinatorLib.resolve_split(%{ - 1 => 2, - 2 => 3, - 3 => 4, - 4 => 1 - }) - - assert result == %{} - - # Endless loop with something true - result = - CoordinatorLib.resolve_split(%{ - 1 => 2, - 2 => 3, - 3 => 4, - 4 => 1, - 5 => true - }) - - assert result == %{ - 5 => true - } - end - - test "test minimum player split", %{ - host: _host, - player: player1, - psocket: psocket1, - lobby_id: lobby_id, - empty_lobby_id: empty_lobby_id - } do - %{user: player2, socket: psocket2} = tachyon_auth_setup() - %{user: player3, socket: psocket3} = tachyon_auth_setup() - %{user: player4, socket: psocket4} = tachyon_auth_setup() - %{user: player5, socket: _psocket5} = tachyon_auth_setup() - %{user: player6, socket: _psocket6} = tachyon_auth_setup() - - # Add players to the lobby - Lobby.add_user_to_battle(player2.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player3.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player4.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player5.id, lobby_id, "script_password") - Lobby.add_user_to_battle(player6.id, lobby_id, "script_password") - - # Normally the player joins through the standard means but we're doing a test so it's a bit janky atm - send(Client.get_client_by_id(player1.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player2.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player3.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player4.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player5.id).tcp_pid, {:put, :lobby_id, lobby_id}) - send(Client.get_client_by_id(player6.id).tcp_pid, {:put, :lobby_id, lobby_id}) - - data = %{cmd: "c.lobby.message", message: "$splitlobby 3"} - _tachyon_send(psocket1, data) - - # Check state - split = Coordinator.call_consul(lobby_id, {:get, :split}) - assert split.first_splitter_id == player1.id - assert split.splitters == %{} - - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$n"}) - _tachyon_send(psocket2, %{cmd: "c.lobby.message", message: "$n"}) - :timer.sleep(200) - - # Time to resolve - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$dosplit"}) - :timer.sleep(200) - - # Split should fail, no one followed - assert Client.get_client_by_id(player1.id).lobby_id == lobby_id - assert Client.get_client_by_id(player2.id).lobby_id == lobby_id - assert Client.get_client_by_id(player3.id).lobby_id == lobby_id - assert Client.get_client_by_id(player4.id).lobby_id == lobby_id - - # Split only if 3 players agree - data = %{cmd: "c.lobby.message", message: "$splitlobby 3"} - _tachyon_send(psocket1, data) - - # Check state - split = Coordinator.call_consul(lobby_id, {:get, :split}) - assert split.first_splitter_id == player1.id - assert split.splitters == %{} - - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket2, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket3, %{cmd: "c.lobby.message", message: "$y"}) - _tachyon_send(psocket4, %{cmd: "c.lobby.message", message: "$y"}) - :timer.sleep(200) - - # Time to resolve - _tachyon_send(psocket1, %{cmd: "c.lobby.message", message: "$dosplit"}) - :timer.sleep(200) - - # Split should pass, 4 people agreed to split - assert Client.get_client_by_id(player1.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player2.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player3.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player4.id).lobby_id == empty_lobby_id - assert Client.get_client_by_id(player5.id).lobby_id == lobby_id - assert Client.get_client_by_id(player6.id).lobby_id == lobby_id - end -end diff --git a/test/teiserver_web/controllers/admin/user_controller_test.exs b/test/teiserver_web/controllers/admin/user_controller_test.exs index bd2309b0b..5874e27c0 100644 --- a/test/teiserver_web/controllers/admin/user_controller_test.exs +++ b/test/teiserver_web/controllers/admin/user_controller_test.exs @@ -135,87 +135,4 @@ defmodule TeiserverWeb.Admin.UserControllerTest do # assert conn.private[:phoenix_flash]["danger"] == "Error with rename: Max length 20 characters" end end - - # Report action takes place through the hookserver which isn't firing in this mode - # describe "moderation" do - # test "apply temporary mute", %{conn: conn} do - # %{user: user} = TeiserverTestLib.tachyon_auth_setup() - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # assert cached_user.muted == [false, nil] - - # conn = put(conn, Routes.ts_admin_user_path(conn, :perform_action, user.id, "report_action"), %{ - # report_response_action: "Mute", - # reason: "test reason", - # until: "5 minutes" - # }) - # assert redirected_to(conn) == ~p"/teiserver/admin/user/#{user.id}" <> "#reports_tab" - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # [muted, until] = cached_user.muted - # assert muted == true - # assert until != nil - # end - - # test "apply permanent mute", %{conn: conn} do - # %{user: user} = TeiserverTestLib.tachyon_auth_setup() - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # assert cached_user.muted == [false, nil] - - # conn = put(conn, Routes.ts_admin_user_path(conn, :perform_action, user.id, "report_action"), %{ - # report_response_action: "Mute", - # reason: "test reason", - # until: "never" - # }) - # assert redirected_to(conn) == ~p"/teiserver/admin/user/#{user.id}" <> "#reports_tab" - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # [muted, until] = cached_user.muted - # assert muted == true - # assert until == nil - # end - - # test "apply temporary ban", %{conn: conn} do - # %{user: user} = TeiserverTestLib.tachyon_auth_setup() - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # assert cached_user.banned == [false, nil] - # assert Client.get_client_by_id(user.id) - - # conn = put(conn, Routes.ts_admin_user_path(conn, :perform_action, user.id, "report_action"), %{ - # report_response_action: "Ban", - # reason: "test reason", - # until: "5 minutes" - # }) - # assert redirected_to(conn) == ~p"/teiserver/admin/user/#{user.id}" <> "#reports_tab" - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # [banned, until] = cached_user.banned - # assert banned == true - # assert until != nil - # assert Client.get_client_by_id(user.id) == nil - # end - - # test "apply permanent ban", %{conn: conn} do - # %{user: user} = TeiserverTestLib.tachyon_auth_setup() - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # assert cached_user.banned == [false, nil] - # assert Client.get_client_by_id(user.id) - - # conn = put(conn, Routes.ts_admin_user_path(conn, :perform_action, user.id, "report_action"), %{ - # report_response_action: "Ban", - # reason: "test reason", - # until: "never" - # }) - # assert redirected_to(conn) == ~p"/teiserver/admin/user/#{user.id}" <> "#reports_tab" - - # cached_user = UserCacheLib.get_user_by_id(user.id) - # [banned, until] = cached_user.banned - # assert banned == true - # assert until == nil - # assert Client.get_client_by_id(user.id) == nil - # end - # end end diff --git a/test/teiserver_web/controllers/api/spads_controller_test.exs b/test/teiserver_web/controllers/api/spads_controller_test.exs index 9476f7f28..66b24d940 100644 --- a/test/teiserver_web/controllers/api/spads_controller_test.exs +++ b/test/teiserver_web/controllers/api/spads_controller_test.exs @@ -8,10 +8,6 @@ defmodule TeiserverWeb.API.SpadsControllerTest do import Teiserver.TeiserverTestLib, only: [ - tachyon_auth_setup: 0, - _tachyon_send: 2, - _tachyon_recv: 1, - tachyon_auth_setup: 1, new_user: 0, new_user: 1 ] @@ -99,79 +95,5 @@ defmodule TeiserverWeb.API.SpadsControllerTest do assert data == %{} end - - @tag :needs_attention - test "good data", %{conn: conn} do - Coordinator.start_coordinator() - %{socket: hsocket, user: host} = tachyon_auth_setup() - - # User needs to be a moderator (at this time) to start/stop Coordinator mode - User.update_user(%{host | moderator: true}) - ClientLib.refresh_client(host.id) - - lobby_data = %{ - cmd: "c.lobby.create", - name: "Coordinator #{:rand.uniform(999_999_999)}", - nattype: "none", - port: 1234, - game_hash: "string_of_characters", - map_hash: "string_of_characters", - map_name: "koom valley", - game_name: "BAR", - engine_name: "spring-105", - engine_version: "105.1.2.3", - settings: %{ - max_players: 16 - } - } - - _tachyon_send(hsocket, %{cmd: "c.lobby.create", lobby: lobby_data}) - [reply] = _tachyon_recv(hsocket) - lobby_id = reply["lobby"]["id"] - - # Player needs to be added to the battle - %{user: u1} = ps1 = new_user("Auger") |> tachyon_auth_setup() - %{user: u2} = ps2 = new_user("Basilica") |> tachyon_auth_setup() - %{user: u3} = ps3 = new_user("Crossbow") |> tachyon_auth_setup() - %{user: u4} = ps4 = new_user("Dagger") |> tachyon_auth_setup() - - rating_type_id = MatchRatingLib.rating_type_name_lookup()["Team"] - - [ps1, ps2, ps3, ps4] - |> Enum.each(fn %{user: user, socket: socket} -> - Lobby.force_add_user_to_lobby(user.id, lobby_id) - # Need the sleep to ensure they all get added to the battle - :timer.sleep(50) - - _tachyon_send(socket, %{ - cmd: "c.lobby.update_status", - client: %{player: true, ready: true} - }) - end) - - # Create some ratings - # higher numbered players have higher ratings - make_rating(u1.id, rating_type_id, 20) - make_rating(u2.id, rating_type_id, 25) - make_rating(u3.id, rating_type_id, 30) - make_rating(u4.id, rating_type_id, 35) - - params = %{ - "bots" => "{}", - "nbTeams" => "2", - "players" => - "{'Auger': {'skill': 19.57, 'color': {'blue': 13, 'red': 185, 'green': 87}, 'sigma': 8.07, 'battleStatus': {'ready': 1, 'bonus': 0, 'id': 1, 'side': 0, 'sync': 1, 'team': 0, 'mode': 1}, 'ip': None, 'scriptPass': '---pass---', 'port': None}, 'Basilica': {'scriptPass': '---pass---', 'port': None, 'skill': 27.47, 'color': {'blue': 0, 'red': 255, 'green': 0}, 'ip': None, 'battleStatus': {'mode': 1, 'team': 0, 'sync': 1, 'id': 0, 'side': 1, 'ready': 0, 'bonus': 0}, 'sigma': 5.11}, 'Crossbow': {'skill': 19.57, 'color': {'blue': 13, 'red': 185, 'green': 87}, 'sigma': 8.07, 'battleStatus': {'ready': 1, 'bonus': 0, 'id': 1, 'side': 0, 'sync': 1, 'team': 0, 'mode': 1}, 'ip': None, 'scriptPass': '---pass---', 'port': None}, 'Dagger': {'scriptPass': '---pass---', 'port': None, 'skill': 27.47, 'color': {'blue': 0, 'red': 255, 'green': 0}, 'ip': None, 'battleStatus': {'mode': 1, 'team': 0, 'sync': 1, 'id': 0, 'side': 1, 'ready': 0, 'bonus': 0}, 'sigma': 5.11}}", - "teamSize" => "1.0" - } - - conn = get(conn, Routes.ts_spads_path(conn, :balance_battle, params)) - response = response(conn, 200) - data = Jason.decode!(response) - - # Due to fuzzing of values we can see the imbalance indicator change - # It can go as high as 2 - assert Enum.member?([2, 1, 0], data["unbalance_indicator"]) - assert Map.keys(data["player_assign_hash"]) == ["Auger", "Basilica", "Crossbow", "Dagger"] - end end end diff --git a/test/teiserver_web/live/battle_live_test.exs b/test/teiserver_web/live/battle_live_test.exs index 59ee0285a..82ad0fcf7 100644 --- a/test/teiserver_web/live/battle_live_test.exs +++ b/test/teiserver_web/live/battle_live_test.exs @@ -5,7 +5,7 @@ defmodule TeiserverWeb.Live.BattleTest do alias Central.Helpers.GeneralTestLib alias Teiserver.{Battle, TeiserverTestLib, Lobby} - import Teiserver.TeiserverTestLib, only: [_send_raw: 2, _recv_until: 1, _tachyon_send: 2] + import Teiserver.TeiserverTestLib, only: [_send_raw: 2, _recv_until: 1] import Teiserver.Helper.NumberHelper, only: [int_parse: 1] @throttle_wait 500 + 100 @@ -161,76 +161,6 @@ defmodule TeiserverWeb.Live.BattleTest do live(conn, "/battle/lobbies/show/0") end - @tag :needs_attention - test "chat - valid battle", %{conn: conn} do - # Lets create a battle - %{socket: host_socket, user: host_user} = TeiserverTestLib.auth_setup() - CacheUser.add_roles(host_user, ["Bot"]) - - _send_raw( - host_socket, - "OPENBATTLE 0 0 empty 322 16 gameHash 0 mapHash engineName\tengineVersion\tSpeed metal\tLiveBattleShow\tgameName\n" - ) - - reply = - _recv_until(host_socket) - |> String.split("\n") - - [ - _opened, - _open, - join, - _tags, - _battle_status, - _battle_opened - | _ - ] = reply - - lobby_id = - join - |> String.replace("JOINBATTLE ", "") - |> String.replace(" gameHash", "") - |> int_parse - - Battle.set_modoption(lobby_id, "server/match/uuid", UUID.uuid1()) - {:ok, view, _html} = live(conn, "/battle/lobbies/chat/#{lobby_id}") - - %{user: user1, socket: socket1} = TeiserverTestLib.tachyon_auth_setup() - %{user: user2, socket: _socket2} = TeiserverTestLib.tachyon_auth_setup() - %{user: user3, socket: _socket3} = TeiserverTestLib.tachyon_auth_setup() - - Lobby.force_add_user_to_lobby(user1.id, lobby_id) - Lobby.force_add_user_to_lobby(user2.id, lobby_id) - Lobby.force_add_user_to_lobby(user3.id, lobby_id) - :timer.sleep(@throttle_wait) - - html = render(view) - assert html =~ "#{user1.name}" - assert html =~ "#{user2.name}" - assert html =~ "#{user3.name}" - refute html =~ "Standard message" - - _recv_until(socket1) - - data = %{cmd: "c.lobby.message", message: "Standard messages"} - _tachyon_send(socket1, data) - - # reply = - # _recv_until(socket1) - # |> String.split("\n") - - :timer.sleep(@throttle_wait) - - html = render(view) - assert html =~ "Standard message" - - # Battle closes - Lobby.close_lobby(lobby_id) - :timer.sleep(@throttle_wait) - - assert_redirect(view, "/battle/lobbies", 250) - end - test "chat - no battle", %{conn: conn} do assert {:error, {:redirect, %{to: "/battle/lobbies"}}} = live(conn, "/battle/lobbies/chat/0")