Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
HandshakeHandler.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <string>
5
6#include "core/Args.hpp"
7#include "core/GameClock.hpp"
8#include "core/World.hpp"
11
12using PromotedCallback = std::function<void(int connectionId, int playerId)>;
13
23 public:
24 HandshakeHandler(ClientManager& clients, World& world, GuiNotifier& notifier,
25 const ServerConfig& config, const GameClock& clock,
26 PromotedCallback onPromoted);
27
29 void onNewConnection(int connectionId);
31 void onLine(int connectionId, const std::string& line);
32
33 private:
34 void _promoteToGui(int connectionId);
35 void _promoteToAi(int connectionId, const std::string& teamName);
36 void _reject(int connectionId);
37
44};
std::function< void(int connectionId, int playerId)> PromotedCallback
Owns every client socket and runs the poll() loop.
Single owner of game frequency and elapsed game time.
Definition GameClock.hpp:22
Handles the first exchange with a new socket.
void onNewConnection(int connectionId)
New socket: send the "WELCOME" greeting.
const ServerConfig & _config
const GameClock & _clock
void onLine(int connectionId, const std::string &line)
The client's reply (its team name).
void _promoteToGui(int connectionId)
GuiNotifier & _notifier
void _reject(int connectionId)
PromotedCallback _onPromoted
ClientManager & _clients
void _promoteToAi(int connectionId, const std::string &teamName)
Pure game state - no networking, no scheduling.
Definition World.hpp:47
Represents the configuration for the server application, described by:
Definition Args.hpp:17