Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ def __init__(self):
# The method for choosing map pool rating
# Can be "mean", "min", or "max"
self.MAP_POOL_RATING_SELECTION = "mean"
# The maximum amount of time in seconds to wait between pops
# The maximum amount of time (in seconds) to wait between pops.
self.QUEUE_POP_TIME_MAX = 90
# The number of possible matches we would like to have when the queue
# pops. The queue pop time will be adjusted based on the current rate of
# players queuing to try and hit this number.
self.QUEUE_POP_DESIRED_MATCHES = 2.5
# How many previous queue sizes to consider
self.QUEUE_POP_TIME_MOVING_AVG_SIZE = 5
# Amount of time (in seconds) that players have to accept a match
# before it will time out.
self.MATCH_OFFER_TIME = 20

self._defaults = {
key: value for key, value in vars(self).items() if key.isupper()
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
Loading