Skip to content

Commit

Permalink
v2 - Remove Deprecations (#816)
Browse files Browse the repository at this point in the history
* Remove modvault

* Remove create_account

* Remove id and login from welcome message

* Remove mod from game_matchmaking command

* Remove QDataStreamProtocol

* Remove 'faction' parameter from game_matchmaking command

* Stop sending game_launch when match is cancelled

* Remove InitMode

* Remove search boundaries from matchmaker_info
  • Loading branch information
Askaholic committed Jan 2, 2024
1 parent 999ce6f commit da5ec4c
Show file tree
Hide file tree
Showing 30 changed files with 140 additions and 406 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ USER faf
# Main entrypoint and the default command that will be run
CMD ["/usr/local/bin/python3", "main.py"]

# lobby server runs on 8001/tcp (QDataStream) and 8002/tcp (JSON)
EXPOSE 8001 8002
# lobby server runs on 8002/tcp (JSON)
EXPOSE 8002

RUN python3 -V
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,8 @@ list see [https://faforever.github.io/server/](https://faforever.github.io/serve
The protocol is mainly JSON-encoded maps, containing at minimum a `command` key,
representing the command to dispatch.

The wire format uses [QDataStream](http://doc.qt.io/qt-5/qdatastream.html) (UTF-16, BigEndian).

For the lobbyconnection, each message is of the form:
```
ACTION: QString
```
With most carrying a footer containing:
```
LOGIN: QString
SESSION: QString
```

## Incoming Packages

##### Mod Vault

- (deprecated) `{command: modvault, type: start}`: show the last 100 mods
- (deprecated) `{command: modvault, type: like, uid: <uid>}`: check if user liked the mod, otherwise increase the like counter
- (deprecated) `{command: modvault, type: download, uid: <uid>}`: notify server about a download (for download counter), does not start the download

##### Social
- `{command: social_add, friend|foe: <player_id>}`: Add a friend or foe
- `{command: social_remove, friend|foe: <player_id>}`: Remove a friend or foe
Expand Down
8 changes: 4 additions & 4 deletions e2e_tests/fafclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from websockets.client import connect as ws_connect

from server.protocol import QDataStreamProtocol, SimpleJsonProtocol
from server.protocol import SimpleJsonProtocol
from tests.integration_tests.conftest import read_until, read_until_command

from .websocket_protocol import WebsocketProtocol
Expand Down Expand Up @@ -32,7 +32,7 @@ async def close(self):

await self.proto.close()

async def connect(self, host, port, protocol_class=QDataStreamProtocol):
async def connect(self, host, port, protocol_class=SimpleJsonProtocol):
self.proto = protocol_class(
*(await asyncio.open_connection(host, port))
)
Expand Down Expand Up @@ -104,8 +104,8 @@ async def login(self, username, password):
"unique_id": unique_id
})
msg = await self.read_until_command("welcome")
self.player_id = msg["id"]
self.player_name = msg["login"]
self.player_id = msg["me"]["id"]
self.player_name = msg["me"]["login"]
return msg

def get_unique_id(self, session):
Expand Down
3 changes: 1 addition & 2 deletions e2e_tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ async def test_user_existence(client_factory, username):
"""Verify that these users exist on the test server"""
client, welcome_message = await client_factory.login(username, "foo")

assert welcome_message["login"] == welcome_message["me"]["login"] == username
assert welcome_message["id"] == welcome_message["me"]["id"]
assert welcome_message["me"]["login"] == username
assert client.is_connected()
4 changes: 2 additions & 2 deletions server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
from .oauth_service import OAuthService
from .party_service import PartyService
from .player_service import PlayerService
from .protocol import Protocol, QDataStreamProtocol
from .protocol import Protocol, SimpleJsonProtocol
from .rating_service.rating_service import RatingService
from .servercontext import ServerContext
from .stats.game_stats_service import GameStatsService
Expand Down Expand Up @@ -231,7 +231,7 @@ async def listen(
self,
address: tuple[str, int],
name: Optional[str] = None,
protocol_class: type[Protocol] = QDataStreamProtocol,
protocol_class: type[Protocol] = SimpleJsonProtocol,
proxy: bool = False,
) -> ServerContext:
"""
Expand Down
2 changes: 0 additions & 2 deletions server/games/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
GameConnectionState,
GameState,
GameType,
InitMode,
ValidityState,
Victory,
VisibilityState
Expand All @@ -40,7 +39,6 @@ class FeaturedMod(NamedTuple):
"GameOptions",
"GameState",
"GameType",
"InitMode",
"LadderGame",
"ValidityState",
"Victory",
Expand Down
3 changes: 1 addition & 2 deletions server/games/coop.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from .game import Game
from .typedefs import FA, GameType, InitMode, ValidityState, Victory
from .typedefs import FA, GameType, ValidityState, Victory


class CoopGame(Game):
"""Class for coop game"""
init_mode = InitMode.NORMAL_LOBBY
game_type = GameType.COOP

def __init__(self, *args, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions server/games/custom_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
from server.rating import RatingType

from .game import Game
from .typedefs import GameType, InitMode, ValidityState
from .typedefs import GameType, ValidityState


@with_logger
class CustomGame(Game):
init_mode = InitMode.NORMAL_LOBBY
game_type = GameType.CUSTOM

def __init__(self, id, *args, **kwargs):
Expand Down
2 changes: 0 additions & 2 deletions server/games/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
GameConnectionState,
GameState,
GameType,
InitMode,
ValidityState,
Victory,
VisibilityState
Expand All @@ -55,7 +54,6 @@ class Game:
"""
Object that lasts for the lifetime of a game on FAF.
"""
init_mode = InitMode.NORMAL_LOBBY
game_type = GameType.CUSTOM

def __init__(
Expand Down
4 changes: 1 addition & 3 deletions server/games/ladder_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from .game import Game
from .game_results import ArmyOutcome, GameOutcome
from .typedefs import GameState, GameType, InitMode
from .typedefs import GameState, GameType

logger = logging.getLogger(__name__)

Expand All @@ -23,8 +23,6 @@ def __init__(self, player: Player):

class LadderGame(Game):
"""Class for 1v1 ladder games"""

init_mode = InitMode.AUTO_LOBBY
game_type = GameType.MATCHMAKER

def __init__(self, id, *args, **kwargs):
Expand Down
7 changes: 0 additions & 7 deletions server/games/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ class GameConnectionState(Enum):
ENDED = 3


@unique
class InitMode(Enum):
NORMAL_LOBBY = 0
AUTO_LOBBY = 1


@unique
class GameType(Enum):
COOP = "coop"
Expand Down Expand Up @@ -224,7 +218,6 @@ class FA(object):
"GameConnectionState",
"GameState",
"GameType",
"InitMode",
"TeamRatingSummary",
"ValidityState",
"Victory",
Expand Down
12 changes: 3 additions & 9 deletions server/ladder_service/ladder_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from server.decorators import with_logger
from server.exceptions import DisabledError
from server.game_service import GameService
from server.games import InitMode, LadderGame
from server.games import LadderGame
from server.games.ladder_game import GameClosedError
from server.ladder_service.game_name import game_name
from server.ladder_service.violation_service import ViolationService
Expand Down Expand Up @@ -535,7 +535,6 @@ def get_displayed_rating(player: Player) -> float:
rating_type=queue.rating_type,
max_players=len(all_players),
)
game.init_mode = InitMode.AUTO_LOBBY
game.set_name_unchecked(game_name(team1, team2))

team1 = sorted(team1, key=get_displayed_rating)
Expand Down Expand Up @@ -643,13 +642,8 @@ async def launch_match(
await game.wait_hosted(60)
except asyncio.TimeoutError:
raise NotConnectedError([host])
finally:
# TODO: Once the client supports `match_cancelled`, don't
# send `launch_game` to the client if the host timed out. Until
# then, failing to send `launch_game` will cause the client to
# think it is searching for ladder, even though the server has
# already removed it from the queue.

try:
# Launch the guests
not_connected_guests = [
player for player in guests
Expand All @@ -666,7 +660,7 @@ async def launch_match(
is_host=False,
options=make_game_options(guest)
)
try:

await game.wait_launched(60 + 10 * len(guests))
except asyncio.TimeoutError:
connected_players = game.get_connected_players()
Expand Down
Loading

0 comments on commit da5ec4c

Please sign in to comment.