|
SuperTuxKart
|
Base class for both client and server lobby. The lobbies are started when a server opens a game, or when a client joins a game. It is used to exchange data about the race settings, like kart selection. More...
#include <lobby_protocol.hpp>

Public Member Functions | |
| virtual void | setup ()=0 |
| A previous GameSetup is deleted and a new one is created. More... | |
| virtual void | update (int ticks)=0 |
| Called by the protocol listener, synchronously with the main loop. More... | |
| virtual void | finishedLoadingWorld ()=0 |
| virtual void | loadWorld () |
| Starts the sychronization protocol and the RaceEventManager. More... | |
| virtual bool | allPlayersReady () const =0 |
| virtual bool | isRacing () const =0 |
| void | startVotingPeriod (float max_time) |
| Starts the voting period time with the specified maximum time. More... | |
| float | getRemainingVotingTime () |
| Returns the remaining voting time in seconds. | |
| bool | isVotingOver () |
| Returns if the voting period is over. | |
| float | getMaxVotingTime () |
| Returns the maximum floating time in seconds. | |
| GameSetup * | getGameSetup () const |
| Returns the game setup data structure. | |
| int | getNumberOfVotes () const |
| Returns the number of votes received so far. | |
| void | addVote (uint32_t host_id, const PeerVote &vote) |
| Adds a vote. More... | |
| const PeerVote * | getVote (uint32_t host_id) const |
| Returns the voting data for one host. More... | |
| void | resetVotingTime () |
| const std::map< uint32_t, PeerVote > & | getAllVotes () const |
| Returns all voting data. | |
| std::pair< uint32_t, uint32_t > | getGameStartedProgress () const |
| void | setGameStartedProgress (const std::pair< uint32_t, uint32_t > &p) |
| void | resetGameStartedProgress () |
| bool | hasLiveJoiningRecently () const |
| void | storePlayingTrack (const std::string &track_ident) |
| std::string | getPlayingTrackIdent () const |
| Track * | getPlayingTrack () const |
Public Member Functions inherited from Protocol | |
| Protocol (ProtocolType type) | |
| Constructor Sets the basic protocol parameters, as the callback object and the protocol type. More... | |
| virtual | ~Protocol () |
| Destructor. | |
| virtual void | asynchronousUpdate ()=0 |
| Called by the protocol listener as often as possible. More... | |
| bool | checkDataSize (Event *event, unsigned int minimum_size) |
| functions to check incoming data easily More... | |
| void | sendMessageToPeers (NetworkString *message, bool reliable=true) |
| Sends a message to all validated peers in game, encrypt the message if needed. More... | |
| void | sendMessageToPeersInServer (NetworkString *message, bool reliable=true) |
| Sends a message to all validated peers in server, encrypt the message if needed. More... | |
| void | sendToServer (NetworkString *message, bool reliable=true) |
| Sends a message from a client to the server. | |
| virtual void | requestStart () |
| Starts a request in the protocol manager to start this protocol. | |
| virtual void | requestTerminate () |
| Submits a request to the ProtocolManager to terminate this protocol. | |
| virtual bool | notifyEvent (Event *event) |
| Notify a protocol matching the Event type of that event. More... | |
| virtual bool | notifyEventAsynchronous (Event *event) |
| Notify a protocol matching the Event type of that event. More... | |
| ProtocolType | getProtocolType () const |
| Method to get a protocol's type. More... | |
| void | setHandleConnections (bool b) |
| Sets if this protocol should receive connection events. | |
| void | setHandleDisconnections (bool b) |
| Sets if this protocol should receive disconnection events. | |
| virtual bool | handleConnects () const |
| Return true if this protocol should be informed about connects. | |
| virtual bool | handleDisconnects () const |
| Return true if this protocol should be informed about disconnects. | |
Static Public Member Functions | |
| template<typename Singleton , typename... Types> | |
| static std::shared_ptr< Singleton > | create (Types ...args) |
| Creates either a client or server lobby protocol as a singleton. | |
| template<class T > | |
| static std::shared_ptr< T > | get () |
| Returns the singleton client or server lobby protocol. | |
| template<class T > | |
| static std::shared_ptr< T > | getByType (ProcessType pt) |
| Returns specific singleton client or server lobby protocol. | |
Protected Member Functions | |
| void | configRemoteKart (const std::vector< std::shared_ptr< NetworkPlayerProfile > > &players, int local_player_size) const |
| void | joinStartGameThread () |
| void | addLiveJoiningKart (int kart_id, const RemoteKartInfo &rki, int live_join_util_ticks) const |
| void | exitGameState () |
Protected Attributes | |
| const ProcessType | m_process_type |
| std::map< uint32_t, PeerVote > | m_peers_votes |
| Vote from each peer. More... | |
| std::atomic< uint64_t > | m_end_voting_period |
| Timer user for voting periods in both lobbies. | |
| uint64_t | m_max_voting_time |
| The maximum voting time. | |
| std::thread | m_start_game_thread |
| std::atomic< uint32_t > | m_estimated_remaining_time |
| Estimated current started game remaining time, uint32_t max if not available. | |
| std::atomic< uint32_t > | m_estimated_progress |
| Estimated current started game progress in 0-100%, uint32_t max if not available. | |
| int | m_last_live_join_util_ticks |
| Save the last live join ticks, for physical objects to update current transformation in server, and reset smooth network body in client. | |
| std::mutex | m_current_track_mutex |
| Mutex to protect m_current_track. | |
| std::string | m_current_track |
| Store current playing track in name. | |
| GameSetup * | m_game_setup |
| Stores data about the online game to play. | |
Protected Attributes inherited from Protocol | |
| ProtocolType | m_type |
| The type of the protocol. | |
| bool | m_handle_connections |
| True if this protocol should receive connection events. | |
| bool | m_handle_disconnections |
| TRue if this protocol should recceiver disconnection events. | |
Static Protected Attributes | |
| static std::weak_ptr< LobbyProtocol > | m_lobby [PT_COUNT] |
Base class for both client and server lobby. The lobbies are started when a server opens a game, or when a client joins a game. It is used to exchange data about the race settings, like kart selection.
| void LobbyProtocol::addVote | ( | uint32_t | host_id, |
| const PeerVote & | vote | ||
| ) |
Adds a vote.
| host_id | Host id of this vote. |
| vote | The vote to add. |
| const PeerVote * LobbyProtocol::getVote | ( | uint32_t | host_id | ) | const |
Returns the voting data for one host.
Returns NULL if the vote from the given host id has not yet arrived (or if it is an invalid host id).
|
virtual |
Starts the sychronization protocol and the RaceEventManager.
It then sets the player structures up, creates the active player, and loads the world. This is called on the client when the server informs them that the world can be loaded (LE_LOAD_WORLD) and on the server in state LOAD_WORLD (i.e. just after informing all clients).
|
pure virtual |
A previous GameSetup is deleted and a new one is created.
Implements Protocol.
Implemented in ServerLobby, and ClientLobby.
| void LobbyProtocol::startVotingPeriod | ( | float | max_time | ) |
Starts the voting period time with the specified maximum time.
| max_time | Maximum voting time in seconds |
|
pure virtual |
Called by the protocol listener, synchronously with the main loop.
Must be re-defined.
Implements Protocol.
Implemented in ServerLobby, and ClientLobby.
|
protected |
Vote from each peer.
The host id is used as a key. Note that host ids can be non-consecutive, so we cannot use std::vector.