Network game manager. More...
Classes | |
struct | GameInfo_t |
struct | GroupInfo_t |
class | GroupInfos |
Array of GroupInfo_t structures. More... | |
struct | MessageError_t |
struct | MessageGameOver_t |
struct | MessageGroupCreated_t |
struct | MessageGroupDeleted_t |
struct | MessageHeader_t |
Base header for a network packet. More... | |
struct | MessageHostChanged_t |
struct | MessageJoinApproved_t |
struct | MessageJoinDenied_t |
struct | MessageJoinRequest_t |
struct | MessageJoinResponse_t |
struct | MessagePlayerAddedToGroup_t |
struct | MessagePlayerJoined_t |
struct | MessagePlayerLeft_t |
struct | MessagePlayerRemovedFromGroup_t |
struct | MessagePlayerTypeChanged_t |
struct | PlayerInfo_t |
class | PlayerInfos |
Array of PlayerInfo_t structures. More... | |
Public Types | |
enum | ePacketMessage { kPacketMessageSystem = 0x80000000U , kPacketMessageJoinRequest , kPacketMessageJoinApproved , kPacketMessageJoinDenied , kPacketMessagePlayerJoined , kPacketMessagePlayerLeft , kPacketMessageHostChanged , kPacketMessageGameOver , kPacketMessageGroupCreated , kPacketMessageGroupDeleted , kPacketMessagePlayerAddedToGroup , kPacketMessagePlayerRemovedFromGroup , kPacketMessagePlayerTypeChanged , kPacketMessageJoinResponse , kPacketMessageError = 0xFFFFFFFFU } |
typedef uint32_t | GameID |
Unique 32 bit code for the current game. | |
typedef uint32_t | PlayerType |
Type of player, spectator, coach. | |
typedef uint32_t | PlayerID |
Typedef for a Player ID. | |
typedef PlayerID | GroupID |
Typedef for a Group ID (Think in terms of Red team vs Blue team for chat) | |
typedef uint_t(*) | JoinRequestProc(void *pContext, Game *pGame, const MessageJoinRequest_t *pMessage, const char *pReasonMessage, MessageJoinResponse_t *pOutput) |
typedef uint_t(*) | MessageHandlerProc(void *pContext, Game *pGame, const MessageHeader_t *pMessage) |
typedef void(*) | CallbackProc(void *pContext, Game *pGame, uint32_t uCode, eError uError, void *pExtra) |
Public Member Functions | |
const Burger::StaticRTTI * | get_StaticRTTI (void) const noexcept override |
Get the description to the class. | |
NetPlay (NetworkManager *pNetworkManager) | |
Default constructor. | |
virtual | ~NetPlay () |
Default destructor. | |
eError | Init (GameID uApplicationID) |
Initialize NetPlay. | |
void | Shutdown (void) |
Shut down NetPlay. | |
NetworkManager * | GetNetworkManager (void) const |
Return pointer to the connected NetworkManager. | |
uintptr_t | GetModuleCount (void) const |
Get the number of active NetworkModule instances. | |
eError | GetModuleInfo (uint_t uModuleIndex, NetworkModuleInfo_t *pOutput) const |
Get information on a specific NetworkModule. | |
eError | AddModule (NetworkModule *pNetworkModule) |
Add a NetworkModule to the active list. | |
eError | RemoveModule (NetworkModule *pNetworkModule) |
Remove a NetworkModule from the active list. | |
NetworkModule * | FindModule (eNetworkProtocol uType) |
Find a NetworkModule using a protocol type. | |
NetworkEndpoint * | NewEndpoint (eNetworkProtocol uType) |
Create a new NetworkEndpoint with a specific protocol. | |
NetworkModuleSettings * | NewSettings (eNetworkProtocol uType, uint32_t uGameID, const char *pGameName) |
Create a new NetworkModuleSettings with a specific protocol. | |
void | SetCallbackHandler (CallbackProc pCallback, void *pCallbackContext) |
void | SetJoinRequestHandler (JoinRequestProc pJoinRequest, void *pJoinRequestContext) |
void | SetMessageHandler (MessageHandlerProc pMessageHandler, void *pMessageHandlerContext) |
void | SetEndpointTimeout (uint32_t uMilliseconds) |
Public Member Functions inherited from Burger::Base | |
const char * | get_class_name (void) const noexcept |
Get the name of the class. | |
virtual | ~Base () noexcept=default |
Destructor. | |
Public Attributes | |
NetworkManager * | m_pNetworkManager |
Parent network manager. | |
LastInFirstOut | m_ModuleList |
Linked list of network protocol managers loaded (TCP/IP, Steam, Xbox Live, etc) | |
JoinRequestProc | m_pJoinRequest |
Pointer to callback function to pre-flight players trying to join this server. | |
void * | m_pJoinRequestContext |
Context for the join request callback. | |
MessageHandlerProc | m_pMessageHandler |
Pointer to the callback that handles non-system messages. | |
void * | m_pMessageHandlerContext |
Context for the non-system messages. | |
CallbackProc | m_pCallback |
Generic callback. | |
void * | m_pCallbackContext |
Context for the generic callback. | |
uint_t | m_bInitialized |
Initialized NetworkManage. | |
uint32_t | m_uTimeOut |
Default timeout before a player is disconnected. | |
uint32_t | m_uEndpointTimeOut |
Default timeout for endpoint connections. | |
uint_t | m_uMaxMessageSize |
Size in bytes of the each message instance in the queue (Fast allocator) | |
uint_t | m_uQueueMaxSize |
Size of the preallocated message queue in instances. | |
GameID | m_uApplicationID |
ID of this application. | |
Static Public Attributes | |
static const Burger::StaticRTTI | g_StaticRTTI |
static const uint32_t | kVersion = 0x10000000U |
Version 10.0.0.0. | |
static const uint32_t | kDefaultTimeout = 5000 |
5 second default timeout | |
static const uint32_t | kDefaultMaxMessageSize = 576 |
Size of the data chunks for the message queue. | |
static const uint32_t | kDefaultQueueSize = 100 |
Default message queue size in instances. | |
static const uint32_t | kQueueGrowSize = 20 |
Number of instances to add to the queue if the queue is emptied. | |
static const uint32_t | kPlayerNameSize = 32 |
Size for the player name. | |
static const uint32_t | kPasswordSize = 32 |
Maximum size for a game password. | |
static const PlayerType | kPlayerTypeContestant = 0 |
Normal player type. | |
static const PlayerType | kPlayerTypeSpectator = 1 |
Non-interactive player type. | |
static const PlayerType | kPlayerTypeCoach = 2 |
Non-interactive player that can communicate with contestants. | |
static const PlayerID | kPlayerAll = 0 |
Special Player ID for sending to all players. | |
static const PlayerID | kPlayerHost = 1 |
Special Player ID for the host computer. | |
static const PlayerID | kPlayerServer = 0xFFFFFFFFU |
Special PlayerID for system messages. | |
Static Public Attributes inherited from Burger::Base | |
static const Burger::StaticRTTI | g_StaticRTTI |
The global description of the class. | |
Private Member Functions | |
NetPlay (const NetPlay &)=delete | |
NetPlay & | operator= (const NetPlay &)=delete |
NetPlay (NetPlay &&)=delete | |
NetPlay & | operator= (NetPlay &&)=delete |
Network game manager.
This class contains the functionality of OpenPlay, DirectPlay and other network game instance abstraction
Upon startup, NetworkModule classes are allocated and added to this class for all protocols such as TCP/IP, IPX/SPX, AppleTalk, Bonjour or others. Since this class can manage multiple modules at the same time, it supports the ability for some clients for a network game to be using different protocols on the same host (Although using this feature disables host migration).
void( *) Burger::NetPlay::CallbackProc(void *pContext, Game *pGame, uint32_t uCode, eError uError, void *pExtra) |
uint32_t Burger::NetPlay::GameID |
Unique 32 bit code for the current game.
Typedef for a Group ID (Think in terms of Red team vs Blue team for chat)
uint_t( *) Burger::NetPlay::JoinRequestProc(void *pContext, Game *pGame, const MessageJoinRequest_t *pMessage, const char *pReasonMessage, MessageJoinResponse_t *pOutput) |
uint_t( *) Burger::NetPlay::MessageHandlerProc(void *pContext, Game *pGame, const MessageHeader_t *pMessage) |
uint32_t Burger::NetPlay::PlayerID |
Typedef for a Player ID.
uint32_t Burger::NetPlay::PlayerType |
Type of player, spectator, coach.
Enumerator | |
---|---|
kPacketMessageSystem | All packets of this ID or higher are exclusively for NetPlay. |
kPacketMessageJoinRequest | Request to join a game (Client to Server) |
kPacketMessageJoinApproved | Request to join is approved (Server to Client) |
kPacketMessageJoinDenied | Join request was denied (Server to Client) |
kPacketMessagePlayerJoined | Player has joined the game (All clients) |
kPacketMessagePlayerLeft | Player has left the game (All clients) |
kPacketMessageHostChanged | Server has migrated to another host (All clients) |
kPacketMessageGameOver | Game has ended. |
kPacketMessageGroupCreated | A group has been created (Red vs. Blue) |
kPacketMessageGroupDeleted | A group has been deleted. |
kPacketMessagePlayerAddedToGroup | Joined a group. |
kPacketMessagePlayerRemovedFromGroup | Player has been removed from a group. |
kPacketMessagePlayerTypeChanged | Type of player has been changed (Spectator, Contestant) |
kPacketMessageJoinResponse | Base response for a join game request (Server to Client) |
kPacketMessageError | Error response for a bad packet. |
|
privatedelete |
|
privatedelete |
Burger::NetPlay::NetPlay | ( | NetworkManager * | pNetworkManager | ) |
Default constructor.
Create a default instance of the NetPlay class
pNetworkManager | A pointer to the manager of all network resources |
|
virtual |
Default destructor.
Shut down all NetworkEndpoint instances and release all data for the NetPlay class
Burger::eError BURGER_API Burger::NetPlay::AddModule | ( | NetworkModule * | pNetworkModule | ) |
Add a NetworkModule to the active list.
pNetworkModule | Pointer to a NetworkModule |
Burger::NetworkModule *BURGER_API Burger::NetPlay::FindModule | ( | eNetworkProtocol | uType | ) |
Find a NetworkModule using a protocol type.
Given a eNetworkProtocol that identifies a specific protocol, return a pointer to the NetworkModule if it exists in the active list. If there are multiple NetworkModule instances that have the same eType, the first one found will be returned.
uType | Type of network protocol to search for. |
|
overridevirtualnoexcept |
Get the description to the class.
This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.
Reimplemented from Burger::Base.
|
inline |
Get the number of active NetworkModule instances.
Burger::eError BURGER_API Burger::NetPlay::GetModuleInfo | ( | uint_t | uModuleIndex, |
NetworkModuleInfo_t * | pOutput ) const |
Get information on a specific NetworkModule.
Iterate over the list and return the NetworkModule in the specific index. If the index is out of bounds, return NULL.
uModuleIndex | Type of network protocol to search for. |
pOutput | Pointer to an uninitialized NetworkModuleInfo_t structure to receive the module description |
|
inline |
Burger::eError BURGER_API Burger::NetPlay::Init | ( | GameID | uApplicationID | ) |
Initialize NetPlay.
If the platform supports networking, this function will initialize the network subsystem and set up everything for starting a network game
Burger::NetworkEndpoint *BURGER_API Burger::NetPlay::NewEndpoint | ( | eNetworkProtocol | uType | ) |
Create a new NetworkEndpoint with a specific protocol.
Given a protocol type, allocate a new NetworkEndpoint using that specific protocol.
uType | Type of network protocol to search for. |
Burger::NetworkModuleSettings *BURGER_API Burger::NetPlay::NewSettings | ( | eNetworkProtocol | uType, |
uint32_t | uGameID, | ||
const char * | pGameName ) |
Create a new NetworkModuleSettings with a specific protocol.
Given a protocol type, allocate a new NetworkModuleSettings using that specific protocol. This structure will be initialized with the defaults for the protocol in question
uType | Type of network protocol to search for. |
uGameID | 32 bit unique game id |
pGameName | Pointer to a "C" string for the server name to be broadcast to the world |
Burger::eError BURGER_API Burger::NetPlay::RemoveModule | ( | NetworkModule * | pNetworkModule | ) |
Remove a NetworkModule from the active list.
Given a pointer to a NetworkModule, search for it in the active list and remove it from the list.
pNetworkModule | Pointer to a NetworkModule to search for |
|
inline |
|
inline |
|
inline |
|
inline |
void BURGER_API Burger::NetPlay::Shutdown | ( | void | ) |
Shut down NetPlay.
Shut down all NetworkEndpoint instances and release all data for the NetPlay class
All NetworkModule instances will be deleted.
|
static |
|
static |
Size of the data chunks for the message queue.
|
static |
Default message queue size in instances.
|
static |
5 second default timeout
|
static |
Maximum size for a game password.
|
static |
Special Player ID for sending to all players.
|
static |
Special Player ID for the host computer.
|
static |
Size for the player name.
|
static |
Special PlayerID for system messages.
|
static |
Non-interactive player that can communicate with contestants.
|
static |
Normal player type.
|
static |
Non-interactive player type.
|
static |
Number of instances to add to the queue if the queue is emptied.
|
static |
Version 10.0.0.0.
uint_t Burger::NetPlay::m_bInitialized |
Initialized NetworkManage.
LastInFirstOut Burger::NetPlay::m_ModuleList |
Linked list of network protocol managers loaded (TCP/IP, Steam, Xbox Live, etc)
CallbackProc Burger::NetPlay::m_pCallback |
Generic callback.
void* Burger::NetPlay::m_pCallbackContext |
Context for the generic callback.
JoinRequestProc Burger::NetPlay::m_pJoinRequest |
Pointer to callback function to pre-flight players trying to join this server.
void* Burger::NetPlay::m_pJoinRequestContext |
Context for the join request callback.
MessageHandlerProc Burger::NetPlay::m_pMessageHandler |
Pointer to the callback that handles non-system messages.
void* Burger::NetPlay::m_pMessageHandlerContext |
Context for the non-system messages.
NetworkManager* Burger::NetPlay::m_pNetworkManager |
Parent network manager.
GameID Burger::NetPlay::m_uApplicationID |
ID of this application.
uint32_t Burger::NetPlay::m_uEndpointTimeOut |
Default timeout for endpoint connections.
uint_t Burger::NetPlay::m_uMaxMessageSize |
Size in bytes of the each message instance in the queue (Fast allocator)
uint_t Burger::NetPlay::m_uQueueMaxSize |
Size of the preallocated message queue in instances.
uint32_t Burger::NetPlay::m_uTimeOut |
Default timeout before a player is disconnected.