Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::NetPlay Class Reference

Network game manager. More...

Inheritance diagram for Burger::NetPlay:
Collaboration diagram for Burger::NetPlay:

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::StaticRTTIget_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.
 
NetworkManagerGetNetworkManager (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.
 
NetworkModuleFindModule (eNetworkProtocol uType)
 Find a NetworkModule using a protocol type.
 
NetworkEndpointNewEndpoint (eNetworkProtocol uType)
 Create a new NetworkEndpoint with a specific protocol.
 
NetworkModuleSettingsNewSettings (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

NetworkManagerm_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
 
NetPlayoperator= (const NetPlay &)=delete
 
 NetPlay (NetPlay &&)=delete
 
NetPlayoperator= (NetPlay &&)=delete
 

Detailed Description

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).

See also
NetworkManager, NetworkModule or NetworkEndpoint

Member Typedef Documentation

◆ CallbackProc

void( *) Burger::NetPlay::CallbackProc(void *pContext, Game *pGame, uint32_t uCode, eError uError, void *pExtra)

◆ GameID

Unique 32 bit code for the current game.

◆ GroupID

Typedef for a Group ID (Think in terms of Red team vs Blue team for chat)

◆ JoinRequestProc

uint_t( *) Burger::NetPlay::JoinRequestProc(void *pContext, Game *pGame, const MessageJoinRequest_t *pMessage, const char *pReasonMessage, MessageJoinResponse_t *pOutput)

◆ MessageHandlerProc

uint_t( *) Burger::NetPlay::MessageHandlerProc(void *pContext, Game *pGame, const MessageHeader_t *pMessage)

◆ PlayerID

Typedef for a Player ID.

◆ PlayerType

Type of player, spectator, coach.

Member Enumeration Documentation

◆ ePacketMessage

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.

Constructor & Destructor Documentation

◆ NetPlay() [1/3]

Burger::NetPlay::NetPlay ( const NetPlay & )
privatedelete

◆ NetPlay() [2/3]

Burger::NetPlay::NetPlay ( NetPlay && )
privatedelete

◆ NetPlay() [3/3]

Burger::NetPlay::NetPlay ( NetworkManager * pNetworkManager)

Default constructor.


Create a default instance of the NetPlay class

Parameters
pNetworkManagerA pointer to the manager of all network resources

◆ ~NetPlay()

Burger::NetPlay::~NetPlay ( )
virtual

Default destructor.


Shut down all NetworkEndpoint instances and release all data for the NetPlay class

Member Function Documentation

◆ AddModule()

Burger::eError BURGER_API Burger::NetPlay::AddModule ( NetworkModule * pNetworkModule)

Add a NetworkModule to the active list.


Parameters
pNetworkModulePointer to a NetworkModule
Returns
Zero on success, non-zero on failure

◆ FindModule()

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.

Parameters
uTypeType of network protocol to search for.
Returns
NULL on failure, a valid pointer on success

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::NetPlay::get_StaticRTTI ( void ) const
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.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

◆ GetModuleCount()

uintptr_t Burger::NetPlay::GetModuleCount ( void ) const
inline

Get the number of active NetworkModule instances.


Returns
Count of active NetworkModule class instances

◆ GetModuleInfo()

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.

Parameters
uModuleIndexType of network protocol to search for.
pOutputPointer to an uninitialized NetworkModuleInfo_t structure to receive the module description
Returns
Zero on success, non-zero on failure

◆ GetNetworkManager()

NetworkManager * Burger::NetPlay::GetNetworkManager ( void ) const
inline

Return pointer to the connected NetworkManager.


Returns
Pointer to the connected NetworkManager

◆ Init()

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

Returns
Zero on success, non-zero on failure

◆ NewEndpoint()

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.

Parameters
uTypeType of network protocol to search for.
Returns
NULL on failure, a valid pointer on success

◆ NewSettings()

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

Parameters
uTypeType of network protocol to search for.
uGameID32 bit unique game id
pGameNamePointer to a "C" string for the server name to be broadcast to the world
Returns
NULL on failure, a valid pointer on success

◆ operator=() [1/2]

NetPlay & Burger::NetPlay::operator= ( const NetPlay & )
privatedelete

◆ operator=() [2/2]

NetPlay & Burger::NetPlay::operator= ( NetPlay && )
privatedelete

◆ RemoveModule()

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.

Parameters
pNetworkModulePointer to a NetworkModule to search for
Returns
Zero on success, non-zero on failure

◆ SetCallbackHandler()

void Burger::NetPlay::SetCallbackHandler ( CallbackProc pCallback,
void * pCallbackContext )
inline

◆ SetEndpointTimeout()

void Burger::NetPlay::SetEndpointTimeout ( uint32_t uMilliseconds)
inline

◆ SetJoinRequestHandler()

void Burger::NetPlay::SetJoinRequestHandler ( JoinRequestProc pJoinRequest,
void * pJoinRequestContext )
inline

◆ SetMessageHandler()

void Burger::NetPlay::SetMessageHandler ( MessageHandlerProc pMessageHandler,
void * pMessageHandlerContext )
inline

◆ Shutdown()

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.

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::NetPlay::g_StaticRTTI
static

◆ kDefaultMaxMessageSize

const uint32_t Burger::NetPlay::kDefaultMaxMessageSize = 576
static

Size of the data chunks for the message queue.

◆ kDefaultQueueSize

const uint32_t Burger::NetPlay::kDefaultQueueSize = 100
static

Default message queue size in instances.

◆ kDefaultTimeout

const uint32_t Burger::NetPlay::kDefaultTimeout = 5000
static

5 second default timeout

◆ kPasswordSize

const uint32_t Burger::NetPlay::kPasswordSize = 32
static

Maximum size for a game password.

◆ kPlayerAll

const PlayerID Burger::NetPlay::kPlayerAll = 0
static

Special Player ID for sending to all players.

◆ kPlayerHost

const PlayerID Burger::NetPlay::kPlayerHost = 1
static

Special Player ID for the host computer.

◆ kPlayerNameSize

const uint32_t Burger::NetPlay::kPlayerNameSize = 32
static

Size for the player name.

◆ kPlayerServer

const PlayerID Burger::NetPlay::kPlayerServer = 0xFFFFFFFFU
static

Special PlayerID for system messages.

◆ kPlayerTypeCoach

const PlayerType Burger::NetPlay::kPlayerTypeCoach = 2
static

Non-interactive player that can communicate with contestants.

◆ kPlayerTypeContestant

const PlayerType Burger::NetPlay::kPlayerTypeContestant = 0
static

Normal player type.

◆ kPlayerTypeSpectator

const PlayerType Burger::NetPlay::kPlayerTypeSpectator = 1
static

Non-interactive player type.

◆ kQueueGrowSize

const uint32_t Burger::NetPlay::kQueueGrowSize = 20
static

Number of instances to add to the queue if the queue is emptied.

◆ kVersion

const uint32_t Burger::NetPlay::kVersion = 0x10000000U
static

Version 10.0.0.0.

◆ m_bInitialized

uint_t Burger::NetPlay::m_bInitialized

Initialized NetworkManage.

◆ m_ModuleList

LastInFirstOut Burger::NetPlay::m_ModuleList

Linked list of network protocol managers loaded (TCP/IP, Steam, Xbox Live, etc)

◆ m_pCallback

CallbackProc Burger::NetPlay::m_pCallback

Generic callback.

◆ m_pCallbackContext

void* Burger::NetPlay::m_pCallbackContext

Context for the generic callback.

◆ m_pJoinRequest

JoinRequestProc Burger::NetPlay::m_pJoinRequest

Pointer to callback function to pre-flight players trying to join this server.

◆ m_pJoinRequestContext

void* Burger::NetPlay::m_pJoinRequestContext

Context for the join request callback.

◆ m_pMessageHandler

MessageHandlerProc Burger::NetPlay::m_pMessageHandler

Pointer to the callback that handles non-system messages.

◆ m_pMessageHandlerContext

void* Burger::NetPlay::m_pMessageHandlerContext

Context for the non-system messages.

◆ m_pNetworkManager

NetworkManager* Burger::NetPlay::m_pNetworkManager

Parent network manager.

◆ m_uApplicationID

GameID Burger::NetPlay::m_uApplicationID

ID of this application.

◆ m_uEndpointTimeOut

uint32_t Burger::NetPlay::m_uEndpointTimeOut

Default timeout for endpoint connections.

◆ m_uMaxMessageSize

uint_t Burger::NetPlay::m_uMaxMessageSize

Size in bytes of the each message instance in the queue (Fast allocator)

◆ m_uQueueMaxSize

uint_t Burger::NetPlay::m_uQueueMaxSize

Size of the preallocated message queue in instances.

◆ m_uTimeOut

uint32_t Burger::NetPlay::m_uTimeOut

Default timeout before a player is disconnected.