|
Zappy Server
C++ game server: world, rules, scheduler, network
|
Handles the first exchange with a new socket. More...
#include <HandshakeHandler.hpp>
Collaboration diagram for HandshakeHandler:Public Member Functions | |
| HandshakeHandler (ClientManager &clients, World &world, GuiNotifier ¬ifier, const ServerConfig &config, const GameClock &clock, PromotedCallback onPromoted) | |
| void | onNewConnection (int connectionId) |
| New socket: send the "WELCOME" greeting. | |
| void | onLine (int connectionId, const std::string &line) |
| The client's reply (its team name). | |
Private Member Functions | |
| void | _promoteToGui (int connectionId) |
| void | _promoteToAi (int connectionId, const std::string &teamName) |
| void | _reject (int connectionId) |
Private Attributes | |
| ClientManager & | _clients |
| World & | _world |
| GuiNotifier & | _notifier |
| const ServerConfig & | _config |
| const GameClock & | _clock |
| PromotedCallback | _onPromoted |
Handles the first exchange with a new socket.
On connect the server sends "WELCOME". The client replies with a team name: "GRAPHIC" becomes a GUI, any other name joins that team as an AI (if a slot is free), anything else is rejected. Once accepted, the connection is promoted to its real type and onPromoted is fired.
Definition at line 22 of file HandshakeHandler.hpp.
| HandshakeHandler::HandshakeHandler | ( | ClientManager & | clients, |
| World & | world, | ||
| GuiNotifier & | notifier, | ||
| const ServerConfig & | config, | ||
| const GameClock & | clock, | ||
| PromotedCallback | onPromoted | ||
| ) |
Definition at line 9 of file HandshakeHandler.cpp.
|
private |
Definition at line 74 of file HandshakeHandler.cpp.
References _clients, _config, _onPromoted, _reject(), _world, World::addPlayer(), AI, ClientManager::getConnection(), ServerConfig::height, World::popEggForTeam(), ClientManager::send(), Connection::setPlayerId(), Connection::setType(), World::teamEggCount(), and ServerConfig::width.
Referenced by onLine().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 49 of file HandshakeHandler.cpp.
References _clients, _clock, _config, _notifier, _world, GuiNotifier::addGui(), World::at(), Serializer::bct(), Serializer::enw(), GameClock::freq(), ClientManager::getConnection(), World::getEggs(), World::getPlayers(), GUI, ServerConfig::height, Serializer::msz(), Serializer::pnw(), Tile::resources, GuiNotifier::send(), Connection::setType(), Serializer::sgt(), Serializer::sse(), ServerConfig::teamNames, Serializer::tna(), and ServerConfig::width.
Referenced by onLine().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 100 of file HandshakeHandler.cpp.
References _clients, ClientManager::disconnect(), and ClientManager::send().
Referenced by _promoteToAi(), and onLine().
Here is the call graph for this function:
Here is the caller graph for this function:| void HandshakeHandler::onLine | ( | int | connectionId, |
| const std::string & | line | ||
| ) |
The client's reply (its team name).
Definition at line 26 of file HandshakeHandler.cpp.
References _config, _promoteToAi(), _promoteToGui(), _reject(), _world, World::isGameEnded(), World::teamEggCount(), and ServerConfig::teamNames.
Referenced by CommandDispatcher::dispatch().
Here is the call graph for this function:
Here is the caller graph for this function:| void HandshakeHandler::onNewConnection | ( | int | connectionId | ) |
New socket: send the "WELCOME" greeting.
Definition at line 21 of file HandshakeHandler.cpp.
References _clients, and ClientManager::send().
Referenced by CommandDispatcher::onNewConnection().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 38 of file HandshakeHandler.hpp.
Referenced by _promoteToAi(), _promoteToGui(), _reject(), and onNewConnection().
|
private |
Definition at line 42 of file HandshakeHandler.hpp.
Referenced by _promoteToGui().
|
private |
Definition at line 41 of file HandshakeHandler.hpp.
Referenced by _promoteToAi(), _promoteToGui(), and onLine().
|
private |
Definition at line 40 of file HandshakeHandler.hpp.
Referenced by _promoteToGui().
|
private |
Definition at line 43 of file HandshakeHandler.hpp.
Referenced by _promoteToAi().
|
private |
Definition at line 39 of file HandshakeHandler.hpp.
Referenced by _promoteToAi(), _promoteToGui(), and onLine().