Server
 All Data Structures Files Functions Variables
Public Member Functions | Protected Member Functions
communication::Communicator Class Reference

#include <Communicator.hpp>

Public Member Functions

 Communicator (MessageHandler &messageHandler, util::Logging &log, const messages::broadcast::MatchConfig &matchConfig)
 
template<typename T >
void send (const messages::AbstractMessage< T > &message, int id)
 
void removeClient (int id, const std::string &name)
 
void removeFromLobbyAfterLeft (bool lobbyEmpty, const std::string &userName, const std::string &lobbyName)
 

Protected Member Functions

void receive (const messages::Message &message, int client)
 

Detailed Description

The communicator is responsible for managing player sessions and lobbys.

Constructor & Destructor Documentation

communication::Communicator::Communicator ( MessageHandler messageHandler,
util::Logging &  log,
const messages::broadcast::MatchConfig &  matchConfig 
)

CTor: Start the communicator with a MessageHandler as a backend.

Parameters
messageHandlerthe message handler to use to send and receive messages
logthe log object which to use
matchConfigthe matchConfig to use for all lobbies instantiated from this communicator

Member Function Documentation

void communication::Communicator::removeClient ( int  id,
const std::string &  name 
)

Remove a client from the lobby, this is used by a lobby to kick a user.

void communication::Communicator::removeFromLobbyAfterLeft ( bool  lobbyEmpty,
const std::string &  userName,
const std::string &  lobbyName 
)

Removes a client after a timeout and closes the lobby if empty

Parameters
lobbyEmptytrue if the player that left was the last player
userNamethe name of the player
lobbyNamethe name of the lobby
template<typename T >
void communication::Communicator::send ( const messages::AbstractMessage< T > &  message,
int  id 
)

Send an abstract message to the communicator

Template Parameters
Ttype of the message payload
Parameters
messagethe message to send
idthe client to which the message should be sent

The documentation for this class was generated from the following files: