![]() |
Open 3D Engine GridMate API Reference
2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
|
#include <Session.h>
Inherits Handler, and Handler.
Classes | |
struct | EventCommand |
struct | NotFullyConnectedMember |
Public Types | |
enum | CarrierChannels { CC_REPLICA_DATA, CC_VOICE_DATA, CC_USER_DATA } |
enum | Result { GS_OK = 0, GS_ERROR } |
Public Member Functions | |
virtual void | Update () |
virtual bool | SendInviteDlg () |
Displays send invite dialog and binds current session data to it. | |
const SessionID & | GetId () const |
unsigned int | GetNumberOfMembers () const |
GridMember * | GetMemberByIndex (unsigned int index) const |
GridMember * | GetMemberById (const MemberID &id) const |
GridMember * | GetMemberById (const MemberIDCompact &id) const |
GridMember * | GetHost () const |
GridMember * | GetMyMember () const |
Result | KickMember (GridMember *member, AZ::u8 reason=0) |
Result | BanMember (GridMember *member, AZ::u8 reason=0) |
virtual Result | LockSession () |
virtual Result | UnlockSession () |
void | Leave (bool isMigrateHost) |
bool | IsHost () const |
bool | IsReady () const |
bool | IsMigratingHost () const |
Return true if we are in host migration state, false otherwise. | |
unsigned int | GetTime () const |
returns time in milliseconds since the session started. | |
SessionTopology | GetTopology () const |
unsigned char | GetNumUsedPublicSlots () const |
unsigned char | GetNumUsedPrivateSlots () const |
unsigned char | GetNumFreePublicSlots () const |
unsigned char | GetNumFreePrivateSlots () const |
unsigned char | GetFlags () const |
unsigned int | GetPeerToPeerTimeout () const |
Returns timeout in milliseconds for the host to tolerate 2 peers with different number of connections. The peer with less connections will be kicked out after that timeout expires. | |
unsigned int | GetHostMigrationTimeout () const |
Return host migration max time in milliseconds. If timeout expires the used will leave the current session. | |
unsigned int | GetHostMigrationVotingTime () const |
Return host migration min voting time. Value between 0 and GetHostMigrationTimeout() / 2 for voting time, before we go to elect the winner. | |
unsigned int | GetNumParams () const |
const GridSessionParam & | GetParam (unsigned int index) const |
bool | SetParam (const GridSessionParam ¶m) |
bool | RemoveParam (const AZStd::string ¶mId) |
bool | RemoveParam (unsigned int index) |
ReplicaManager * | GetReplicaMgr () |
Returns the instance of the replica manager. Replica manager may not be initialized if the session is NOT in ready (created) state. | |
Carrier * | GetCarrier () |
Returns the pointer to the transport layer. The pointer can be NULL if the session is NOT in ready (created) state. | |
const CarrierDesc & | GetCarrierDesc () const |
Returns pointer to the descriptor which was used to create the transport layer (carrier) | |
IGridMate * | GetGridMate () |
Return owner gridmate. | |
void | DebugEnableDisconnectDetection (bool isEnable) |
Debug: Change the disconnect detection state of all members in the session. | |
bool | DebugIsEnableDisconnectDetection () const |
Protected Types | |
enum | BaseStates { SS_TOP, SS_NO_SESSION, SS_START_UP, SS_CREATE, SS_IN_SESSION, SS_JOIN, SS_IDLE, SS_START_GAME, SS_IN_GAME, SS_END_GAME, SS_DELETE, SS_HOST_MIGRATE_ELECTION, SS_HOST_MIGRATE_SESSION, SS_LAST } |
enum | BaseStateEvents { SE_UPDATE, SE_HOST, SE_JOIN, SE_JOIN_INVITE, SE_JOINED, SE_CREATED, SE_START_GAME, SE_LEAVE_GAME, SE_END_GAME, SE_DELETE, SE_DELETED, SE_CONNECTION_LOST, SE_HM_SESSION_MIGRATED, SE_HM_MIGRATE_CLIENT, SE_HM_CLIENT_SESSION_MIGRATED, SE_HM_REPLICAS_MIGRATED, SE_LAST } |
typedef unordered_set< ConnectionID > | ConnectionIDSet |
typedef vector< GridMember * > | MemberArrayType |
typedef vector< NotFullyConnectedMember > | NotConnectedArrayType |
Protected Member Functions | |
GridSession (SessionService *service) | |
bool | Initialize (const CarrierDesc &carrierDesc) |
Base initialization, must be called before all other operations on session. | |
virtual void | Shutdown () |
Called by the system to shutdown all session resources, before it's get deleted. | |
void | SetHandshakeUserData (const void *data, size_t size) |
void | OnIncomingConnection (Carrier *carrier, ConnectionID id) override |
void | OnFailedToConnect (Carrier *carrier, ConnectionID id, CarrierDisconnectReason reason) override |
void | OnConnectionEstablished (Carrier *carrier, ConnectionID id) override |
void | OnDisconnect (Carrier *carrier, ConnectionID id, CarrierDisconnectReason reason) override |
void | OnDriverError (Carrier *carrier, ConnectionID id, const DriverError &error) override |
void | OnSecurityError (Carrier *carrier, ConnectionID id, const SecurityError &error) override |
void | OnNewHost (bool isHost, ReplicaManager *manager) override |
int | ReserveSlot (bool isInvited) |
Return slot type 1 for public slot, 2 private slot and 0 for no slot. | |
void | FreeSlot (int slotType) |
Frees a slot based on a slot type. | |
virtual GridMember * | CreateRemoteMember (const AZStd::string &address, ReadBuffer &data, RemotePeerMode peerMode, ConnectionID connId=InvalidConnectionID)=0 |
Creates remote player, when he wants to join. | |
virtual bool | IsAddressInMemberList (const AZStd::string &address) |
Returns true if this address belongs to a member in the list, otherwise false. | |
virtual bool | IsConnectionIdInMemberList (const ConnectionID &connId) |
virtual bool | AddMember (GridMember *member) |
Adds a created member to the session. Return false if no free slow was found! | |
virtual bool | RemoveMember (const MemberID &id) |
Remove and delete current member from the session. | |
virtual void | ElectNewHost () |
Called by the state machine to elect a new host. | |
void | CastNewHostVote (GridMember *newHost) |
Called by default from ElectNewHost to cast the new host vote. | |
virtual void | OnSessionParamChanged (const GridSessionParam ¶m)=0 |
Called when a session parameter is added/changed. | |
virtual void | OnSessionParamRemoved (const AZStd::string ¶mId)=0 |
Called when a session parameter is deleted. | |
virtual void | SetUpStateMachine () |
virtual bool | OnStateNoSession (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateStartup (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateCreate (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateInSession (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateJoin (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateIdle (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateStart (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateInGame (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateEnd (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateDelete (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateHostMigrateElection (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual bool | OnStateHostMigrateSession (AZ::HSM &sm, const AZ::HSM::Event &e) |
virtual void | RequestEvent (int id, const void *userData, unsigned int userDataSize, bool isProcessRequired, EventCommand::DataCloner cloner=nullptr, EventCommand::DataDeleter deleter=nullptr) |
virtual void | ProcessEvents () |
If you queue events, you can override this function to process them when appropriate. | |
template<class T > | |
void | RequestEventData (int id, const T &userData, bool isProcessRequired=false) |
T must be copy constructible. | |
void | RequestEventParam (int id, size_t param, bool isProcessRequired=false) |
void | RequestEvent (int id, bool isProcessRequired=false) |
void | EventToQueue (const AZ::HSM::Event &event, unsigned int userDataSize, bool isProcessRequired, EventCommand::DataCloner cloner, EventCommand::DataDeleter deleter) |
void | ProcessEventOnQueue () |
Protected Attributes | |
SessionID | m_sessionId |
Session id. Content of the string will vary based on session types and platforms. | |
CarrierDesc | m_carrierDesc |
Carrier * | m_carrier |
ReplicaManager * | m_replicaMgr |
Internal::GridSessionHandshake * | m_handshake |
ConnectionIDSet | m_connections |
AZStd::string | m_hostAddress |
bool | m_isShutdown |
GridMember * | m_myMember |
Created with the session and bound when the server replica arrives. | |
AZStd::intrusive_ptr< Internal::GridSessionReplica > | m_state |
Pointer to HOST owned session state. | |
SessionService * | m_service |
Pointer to session service. | |
IGridMate * | m_gridMate |
Pointer to the owner GridMate interface. | |
MemberArrayType | m_members |
List of valid members. | |
unordered_set< Internal::GridMemberStateReplica * > | m_unboundMemberStates |
TimeStamp | m_hostMigrationStart |
Time when the host migration started. | |
unsigned int | m_hostMigrationTimeOut |
Host migration time out in milliseconds. | |
unsigned int | m_hostMigrationVotingTime |
Minimum time that we will spend in SS_HOST_MIGRATE_ELECTION state (before we check for majority). It should be < than m_hostMigrationTimeOut/2. | |
bool | m_hostMigrationInProcess |
True if we are in host migration, otherwise false. More... | |
bool | m_hostMigrationSessionMigrated |
bool | m_hostMigrationReplicaMigrated |
NotConnectedArrayType | m_membersNotFullyConnected |
TimeStamp | m_lastConnectivityUpdate |
queue< EventCommand > | m_eventQueue |
Queue with events for the state machine to process. | |
AZ::HSM | m_sm |
Hierarchical state machine for the session management;. | |
AZStd::chrono::milliseconds | m_disconnectKickedPlayersDelay |
number of milliseconds before forcing kicked player to disconnect | |
GridMate::vector< AZStd::pair< TimeStamp, MemberIDCompact > > | m_futureKickedPlayers |
Friends | |
class | GridMember |
class | SessionService |
Session interface class.
|
protected |
void GridMate::GridSession::Leave | ( | bool | isMigrateHost | ) |
Leaves the session. If the local system is the host, isMigrateHost will determine the host migration. If the local system is NOT the host, it will just leave the session.
|
protectedvirtual |
Request a state machine event. You might override and queue the events if you have async operations. if isProcessRequired is set to true, the event dispatch will verify that a state function returned true (processed the event) otherwise it will trigger an assert and dispatch(SE_DELETE) event.
|
protected |
Sets the GridSessionHandshake user data, which will be delivered with each connection request and passed as a ReadBuffer into CreateRemoteMember.
|
protected |
True if we are in host migration, otherwise false.