Emergency 20 Dokumentation  4.2.0
em5::multiplayer::SessionBase Class Referenceabstract

EMERGENCY 5 multiplayer session base class. More...

#include <SessionBase.h>

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

Classes

struct  ChatMessage
 
struct  PlayerInfo
 

Public Types

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
}
 

Public Member Functions

 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 ()
 
virtual bool startup (qsf::Map &map)=0
 Is called when the map was successfully loaded but before game is initialized. More...
 
virtual void loadingFinished ()=0
 Is called when the map was successfully loaded and any further game initializations where done. More...
 

Static Public Member Functions

static void generateContentAuthenticationChecksums (ContentAuthenticationChecksums &checksums)
 

Public Attributes

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
 

Static Public Attributes

static const uint32 CHAT_HISTORY_SIZE
 

Protected Member Functions

virtual void onSendChatMessage (const ChatMessage &chatMessage)=0
 
virtual void onChatMessageReceived (const ChatMessage &chatMessage)
 
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...
 

Protected Attributes

std::unordered_map< uint32, PlayerInfomPlayerInfoMap
 key=playerIndex value=PlayerInfo More...
 

Detailed Description

EMERGENCY 5 multiplayer session base class.

Member Enumeration Documentation

State changes definition

  • Host NONE -> LOBBY
    • When create session is called and anything went fine -> Now connections are accepted LOBBY -> LOADING_SCREEN
    • When loadMap is called and every client is ready (e.g. the hosting player presses the "start game" button in the lobby view) -> Any further connections are denied LOADING_SCREEN -> IN_GAME
    • When onGameStart is called (e.g. the player presses the "start game" button on the loading screen) -> Any further connections are denied IN_GAME -> POST_GAME
  • Client NONE -> CONNECTING_TO_HOST
    • When joinSession is called CONNECTING_TO_HOST -> CONNECTED_TO_HOST
    • When connection to host was successfully CONNECTED_TO_HOST-> LOBBY
    • When connection to the host succeeded and the join request was accepted LOBBY -> LOADING_SCREEN
    • When the host sends the "load map" operation message LOADING_SCREEN -> IN_GAME
    • When the host sends the "start game" operation message IN_GAME -> POST_GAME
Enumerator
NONE 

Used by both: Initial state after an instance was created.

CONNECTING_TO_HOST 

Only used by an client to signal that the client tries to connect to the host.

CONNECTED_TO_HOST 

Only used by an client to signal that the client is connected to the host -> next step join request.

LOBBY 

Used by both to signal that they are currently in the "Lobby" state (Host accepts join request)

LOADING_SCREEN 

Used by both to signal that the map is currently loading (At this state the host denies any further join requests)

IN_GAME 

Used by both to signal that the game is currently running (At this state the host denies any further join requests)

POST_GAME 
POST_GAME_FINISH 

Gets set after highscore publish is accepted/declined.

Constructor & Destructor Documentation

em5::multiplayer::SessionBase::SessionBase ( )

Default constructor.

virtual em5::multiplayer::SessionBase::~SessionBase ( )
virtual

Destructor.

Member Function Documentation

void em5::multiplayer::SessionBase::addChatMessage ( const ChatMessage message)
protected
void em5::multiplayer::SessionBase::clearChatHistory ( )
protected
static void em5::multiplayer::SessionBase::generateContentAuthenticationChecksums ( ContentAuthenticationChecksums checksums)
static
const std::list<ChatMessage>& em5::multiplayer::SessionBase::getChatHistory ( ) const
State em5::multiplayer::SessionBase::getCurrentState ( ) const
uint32 em5::multiplayer::SessionBase::getDuration ( ) const
multiplayer::GameMode em5::multiplayer::SessionBase::getGameMode ( ) const
const std::string& em5::multiplayer::SessionBase::getGameModificationString ( ) const
qsf::GlobalAssetId em5::multiplayer::SessionBase::getGlobalMapAssetId ( ) const
uint32 em5::multiplayer::SessionBase::getLocalPlayerIndex ( ) const
uint8 em5::multiplayer::SessionBase::getMapQualityToUse ( ) const
uint32 em5::multiplayer::SessionBase::getMaximumPlayerCount ( ) const
OperationMessageHandlerManager& em5::multiplayer::SessionBase::getOperationMessageHandlerManager ( )
const PlayerInfo* em5::multiplayer::SessionBase::getPlayerByIndex ( uint32  playerIndex) const
const std::unordered_map<uint32, PlayerInfo>& em5::multiplayer::SessionBase::getPlayerList ( ) const
const std::string& em5::multiplayer::SessionBase::getSessionName ( ) const
const std::string& em5::multiplayer::SessionBase::getSessionPassword ( ) const
void em5::multiplayer::SessionBase::handleChatMessageData ( uint64  dataSize,
const qsf::game::BitStream bitStream 
)
protected
bool em5::multiplayer::SessionBase::isUsingPlayerSeparation ( ) const
virtual void em5::multiplayer::SessionBase::loadingFinished ( )
pure virtual

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

Implemented in em5::multiplayer::server::Host, and em5::multiplayer::client::Client.

virtual void em5::multiplayer::SessionBase::onChatMessageReceived ( const ChatMessage chatMessage)
protectedvirtual

Reimplemented in em5::multiplayer::server::Host.

void em5::multiplayer::SessionBase::onPlayerUserDataChanged ( uint32  playerIndex,
uint32  userData 
)
protected
virtual void em5::multiplayer::SessionBase::onSendChatMessage ( const ChatMessage chatMessage)
protectedpure virtual
void em5::multiplayer::SessionBase::sendChatMessage ( const std::string &  message)
void em5::multiplayer::SessionBase::setCurrentState ( State  state)
protected
void em5::multiplayer::SessionBase::setDuration ( uint32  duration)
protected
void em5::multiplayer::SessionBase::setGameMode ( multiplayer::GameMode  mode)
protected
void em5::multiplayer::SessionBase::setGameModificationString ( const std::string &  string)
protected
void em5::multiplayer::SessionBase::setGlobalMapAssetId ( qsf::GlobalAssetId  globalAssetId)
protected
void em5::multiplayer::SessionBase::setLocalPlayerIndex ( uint32  localPlayerIndex)
protected
void em5::multiplayer::SessionBase::setMaximumPlayerCount ( uint32  count)
protected
void em5::multiplayer::SessionBase::setSessionName ( const std::string &  name)
protected
void em5::multiplayer::SessionBase::setSessionPassword ( const std::string &  password)
protected
void em5::multiplayer::SessionBase::setupGameSession ( )
protected
void em5::multiplayer::SessionBase::setupMap ( qsf::Map map)
protected

Common modifications of the map for host and client.

void em5::multiplayer::SessionBase::setUsingPlayerSeparation ( bool  isUsingPlayerSeparation)
protected
virtual bool em5::multiplayer::SessionBase::startup ( qsf::Map map)
pure virtual

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

Implemented in em5::multiplayer::server::Host, and em5::multiplayer::client::Client.

Member Data Documentation

const uint32 em5::multiplayer::SessionBase::CHAT_HISTORY_SIZE
static
boost::signals2::signal<void(const ChatMessage&)> em5::multiplayer::SessionBase::chatMessage

void onChatMessage(const ChatMessage& message)

boost::signals2::signal<void(State, State)> em5::multiplayer::SessionBase::currentStateChanged

void onCurrentStateChanged(State prevState, State newState)

boost::signals2::signal<void(const GameModeUpdateData&)> em5::multiplayer::SessionBase::gameModeDataChanged

void onGameModeDataChanged(const GameModeUpdateData& gameModeData)

std::unordered_map<uint32, PlayerInfo> em5::multiplayer::SessionBase::mPlayerInfoMap
protected

key=playerIndex value=PlayerInfo

boost::signals2::signal<void(uint32, bool)> em5::multiplayer::SessionBase::playerChangeReady

void onPlayerChangeReady(uint32 playerIndex, bool isReady)

boost::signals2::signal<void(uint32, const PlayerInfo&)> em5::multiplayer::SessionBase::playerJoined

void onPlayerJoined(uint32 playerIndex, const PlayerInfo& playerInfo)

boost::signals2::signal<void(uint32, const PlayerInfo&)> em5::multiplayer::SessionBase::playerLeft

void onPlayerLeft(uint32 playerIndex, const PlayerInfo& playerInfo)

boost::signals2::signal<void(uint32, uint32)> em5::multiplayer::SessionBase::playerUserDataChanged

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