Emergency 20 Dokumentation  4.2.0
em5::multiplayer::server::Host Class Reference

EMERGENCY 5 multiplayer host class. More...

#include <Host.h>

Inheritance diagram for em5::multiplayer::server::Host:
em5::multiplayer::SessionBase

Public Member Functions

 Host ()
 Constructor. More...
 
virtual ~Host ()
 Destructor. More...
 
bool createSession (const std::string &localUserName, uint16 port, const std::string &sessionPassword, const HostEntry &hostEntry)
 
void createLocalSession (const std::string &dataPath, const MapIdentifier &mapIdentifier)
 Creates a local session. This session is only used for testing the multiplayer serialization part. More...
 
void closeSession ()
 Closes the currently running session and closes all related network connections. More...
 
bool loadMap ()
 Initiates the map loading -> starting the game. More...
 
void onGameStart ()
 Is called when the game itself should run now (e.g. the hosting player clicked on the "start game" button in the loading screen) More...
 
bool areAllPlayersReady ()
 Returns if all players are ready. More...
 
void kickPlayer (uint32 playerIndex)
 Kicks the given player, if exists. More...
 
void changeUserDataForPlayer (uint32 playerIndex, uint32 newUserData)
 Changes userDate for given player, if exists. More...
 
void changeGameModeUpdate (bool finished, uint16 timeleftInSeconds)
 Changes game mode update data(This data is send via normal update) More...
 
void addNewHint (const HintMessage::MessageType messageType, const std::string &message, uint32 playerIndex)
 Add a new hint which should be send to the clients. More...
 
void onNewAudio (AudioUpdateData &data)
 
void onAudioStopped (const uint32 audioId)
 
void onAudioUpdated (AudioUpdateData &data)
 
void onLayerChanged (const qsf::Layer &layer)
 
void sendOperationMessageToClient (uint32 playerIndex, const OperationMessage operationMessageId, const qsf::game::BitStream &operationMessageData)
 Sends data to a given client (identified by player index) More...
 
void sendOperationMessageToAllClients (const OperationMessage operationMessageId, const qsf::game::BitStream &operationMessageData, uint32 excludedPlayerIndex=qsf::getUninitialized< uint32 >(0))
 Sends data to all clients. More...
 
void onSendHighscoreSubmitInitiated ()
 Sends the highscore submit initiated message to all clients. More...
 
void onSendHighscoreSubmitDeclined ()
 Sends the highscore submit declined message to all clients. More...
 
void onNewFireHose (CreateFireHoseData &data)
 
void onSpawnParticle (const uint32 prefabId, const float timeout, const glm::vec3 &position, const glm::vec3 &scale)
 
virtual bool startup (qsf::Map &map) override
 Is called when the map was successfully loaded but before game is initialized. More...
 
virtual void loadingFinished () override
 Is called when the map was successfully loaded and any further game initializations where done. More...
 
void acceptHighsocrePublising ()
 Is called when host want to publish the highscore. More...
 
- Public Member Functions inherited from em5::multiplayer::SessionBase
 SessionBase ()
 Default constructor. More...
 
virtual ~SessionBase ()
 Destructor. More...
 
uint32 getLocalPlayerIndex () const
 
const std::string & getSessionName () const
 
const std::string & getSessionPassword () const
 
uint32 getMaximumPlayerCount () const
 
qsf::GlobalAssetId getGlobalMapAssetId () const
 
multiplayer::GameMode getGameMode () const
 
uint32 getDuration () const
 
const std::string & getGameModificationString () const
 
bool isUsingPlayerSeparation () const
 
uint8 getMapQualityToUse () const
 
State getCurrentState () const
 
const std::list< ChatMessage > & getChatHistory () const
 
const std::unordered_map< uint32, PlayerInfo > & getPlayerList () const
 
const PlayerInfogetPlayerByIndex (uint32 playerIndex) const
 
void sendChatMessage (const std::string &message)
 
OperationMessageHandlerManagergetOperationMessageHandlerManager ()
 

Static Public Member Functions

static void setPlayerColorsToUse (const std::vector< qsf::Color3 > &playerColorsToUse)
 Set a list of colors to use for the players. More...
 
- Static Public Member Functions inherited from em5::multiplayer::SessionBase
static void generateContentAuthenticationChecksums (ContentAuthenticationChecksums &checksums)
 

Public Attributes

boost::signals2::signal< void()> readyForGameStart
 Called when all clients and the host have loaded the map. More...
 
boost::signals2::signal< void()> lostConnectionToProxy
 Called when the host lost its connection to the proxy. More...
 
- Public Attributes inherited from em5::multiplayer::SessionBase
boost::signals2::signal< void(State, State)> currentStateChanged
 
boost::signals2::signal< void(const ChatMessage &)> chatMessage
 
boost::signals2::signal< void(uint32, const PlayerInfo &)> playerJoined
 
boost::signals2::signal< void(uint32, const PlayerInfo &)> playerLeft
 
boost::signals2::signal< void(uint32, bool)> playerChangeReady
 
boost::signals2::signal< void(uint32, uint32)> playerUserDataChanged
 
boost::signals2::signal< void(const GameModeUpdateData &)> gameModeDataChanged
 

Protected Member Functions

virtual void onSendChatMessage (const ChatMessage &chatMessage) override
 
virtual void onChatMessageReceived (const ChatMessage &chatMessage)
 
- Protected Member Functions inherited from em5::multiplayer::SessionBase
void setLocalPlayerIndex (uint32 localPlayerIndex)
 
void setSessionName (const std::string &name)
 
void setSessionPassword (const std::string &password)
 
void setMaximumPlayerCount (uint32 count)
 
void setGlobalMapAssetId (qsf::GlobalAssetId globalAssetId)
 
void setGameMode (multiplayer::GameMode mode)
 
void setDuration (uint32 duration)
 
void setGameModificationString (const std::string &string)
 
void setUsingPlayerSeparation (bool isUsingPlayerSeparation)
 
void setCurrentState (State state)
 
void addChatMessage (const ChatMessage &message)
 
void clearChatHistory ()
 
void handleChatMessageData (uint64 dataSize, const qsf::game::BitStream &bitStream)
 
void setupGameSession ()
 
void onPlayerUserDataChanged (uint32 playerIndex, uint32 userData)
 
void setupMap (qsf::Map &map)
 Common modifications of the map for host and client. More...
 

Additional Inherited Members

- Public Types inherited from em5::multiplayer::SessionBase
enum  State : uint8 {
  State::NONE, State::CONNECTING_TO_HOST, State::CONNECTED_TO_HOST, State::LOBBY,
  State::LOADING_SCREEN, State::IN_GAME, State::POST_GAME, State::POST_GAME_FINISH
}
 
- Static Public Attributes inherited from em5::multiplayer::SessionBase
static const uint32 CHAT_HISTORY_SIZE
 
- Protected Attributes inherited from em5::multiplayer::SessionBase
std::unordered_map< uint32, PlayerInfomPlayerInfoMap
 key=playerIndex value=PlayerInfo More...
 

Detailed Description

EMERGENCY 5 multiplayer host class.

Constructor & Destructor Documentation

em5::multiplayer::server::Host::Host ( )

Constructor.

virtual em5::multiplayer::server::Host::~Host ( )
virtual

Destructor.

Member Function Documentation

void em5::multiplayer::server::Host::acceptHighsocrePublising ( )

Is called when host want to publish the highscore.

void em5::multiplayer::server::Host::addNewHint ( const HintMessage::MessageType  messageType,
const std::string &  message,
uint32  playerIndex 
)

Add a new hint which should be send to the clients.

bool em5::multiplayer::server::Host::areAllPlayersReady ( )

Returns if all players are ready.

void em5::multiplayer::server::Host::changeGameModeUpdate ( bool  finished,
uint16  timeleftInSeconds 
)

Changes game mode update data(This data is send via normal update)

void em5::multiplayer::server::Host::changeUserDataForPlayer ( uint32  playerIndex,
uint32  newUserData 
)

Changes userDate for given player, if exists.

void em5::multiplayer::server::Host::closeSession ( )

Closes the currently running session and closes all related network connections.

void em5::multiplayer::server::Host::createLocalSession ( const std::string &  dataPath,
const MapIdentifier mapIdentifier 
)

Creates a local session. This session is only used for testing the multiplayer serialization part.

Parameters
[in]dataPathThe path where the local host will find the files for the game recorder/command player.
[in]mapIdentifierThe identifier of the map to be used
bool em5::multiplayer::server::Host::createSession ( const std::string &  localUserName,
uint16  port,
const std::string &  sessionPassword,
const HostEntry hostEntry 
)
void em5::multiplayer::server::Host::kickPlayer ( uint32  playerIndex)

Kicks the given player, if exists.

virtual void em5::multiplayer::server::Host::loadingFinished ( )
overridevirtual

Is called when the map was successfully loaded and any further game initializations where done.

Implements em5::multiplayer::SessionBase.

bool em5::multiplayer::server::Host::loadMap ( )

Initiates the map loading -> starting the game.

void em5::multiplayer::server::Host::onAudioStopped ( const uint32  audioId)
void em5::multiplayer::server::Host::onAudioUpdated ( AudioUpdateData data)
virtual void em5::multiplayer::server::Host::onChatMessageReceived ( const ChatMessage chatMessage)
protectedvirtual

Reimplemented from em5::multiplayer::SessionBase.

void em5::multiplayer::server::Host::onGameStart ( )

Is called when the game itself should run now (e.g. the hosting player clicked on the "start game" button in the loading screen)

void em5::multiplayer::server::Host::onLayerChanged ( const qsf::Layer layer)
void em5::multiplayer::server::Host::onNewAudio ( AudioUpdateData data)
void em5::multiplayer::server::Host::onNewFireHose ( CreateFireHoseData data)
virtual void em5::multiplayer::server::Host::onSendChatMessage ( const ChatMessage chatMessage)
overrideprotectedvirtual
void em5::multiplayer::server::Host::onSendHighscoreSubmitDeclined ( )

Sends the highscore submit declined message to all clients.

void em5::multiplayer::server::Host::onSendHighscoreSubmitInitiated ( )

Sends the highscore submit initiated message to all clients.

void em5::multiplayer::server::Host::onSpawnParticle ( const uint32  prefabId,
const float  timeout,
const glm::vec3 &  position,
const glm::vec3 &  scale 
)
void em5::multiplayer::server::Host::sendOperationMessageToAllClients ( const OperationMessage  operationMessageId,
const qsf::game::BitStream operationMessageData,
uint32  excludedPlayerIndex = qsf::getUninitializeduint32 >(0) 
)

Sends data to all clients.

void em5::multiplayer::server::Host::sendOperationMessageToClient ( uint32  playerIndex,
const OperationMessage  operationMessageId,
const qsf::game::BitStream operationMessageData 
)

Sends data to a given client (identified by player index)

static void em5::multiplayer::server::Host::setPlayerColorsToUse ( const std::vector< qsf::Color3 > &  playerColorsToUse)
static

Set a list of colors to use for the players.

Parameters
[in]playerColorsToUseA list of colors to use for players. No change is done when empty
Note
  • The order in the give list equals to the player slot index (the "slot" shown in the lobby window)
  • When less colors then maximum player count is given then the slot index is clamped to max color index
virtual bool em5::multiplayer::server::Host::startup ( qsf::Map map)
overridevirtual

Is called when the map was successfully loaded but before game is initialized.

Implements em5::multiplayer::SessionBase.

Member Data Documentation

boost::signals2::signal<void()> em5::multiplayer::server::Host::lostConnectionToProxy

Called when the host lost its connection to the proxy.

Note
  • Recommended slot signature: void onReadyForGameStart()
boost::signals2::signal<void()> em5::multiplayer::server::Host::readyForGameStart

Called when all clients and the host have loaded the map.

Note
  • Recommended slot signature: void onReadyForGameStart()

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