Open 3D Engine Multiplayer Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Multiplayer::IMultiplayer Class Referenceabstract

IMultiplayer provides insight into the Multiplayer session and its Agents. More...

#include <IMultiplayer.h>

Inherited by Multiplayer::MultiplayerSystemComponent.

Public Member Functions

 AZ_RTTI (IMultiplayer, "{90A001DD-AD31-46C7-9FBE-1059AFB7F5E9}")
 
virtual MultiplayerAgentType GetAgentType () const =0
 
virtual void InitializeMultiplayer (MultiplayerAgentType state)=0
 
virtual bool StartHosting (uint16_t port=UseDefaultHostPort, bool isDedicated=true)=0
 
virtual bool Connect (const AZStd::string &remoteAddress, uint16_t port)=0
 
virtual void Terminate (AzNetworking::DisconnectReason reason)=0
 
virtual void AddClientMigrationStartEventHandler (ClientMigrationStartEvent::Handler &handler)=0
 
virtual void AddClientMigrationEndEventHandler (ClientMigrationEndEvent::Handler &handler)=0
 
virtual void AddEndpointDisconnectedHandler (EndpointDisconnectedEvent::Handler &handler)=0
 
virtual void AddNotifyClientMigrationHandler (NotifyClientMigrationEvent::Handler &handler)=0
 
virtual void AddNotifyEntityMigrationEventHandler (NotifyEntityMigrationEvent::Handler &handler)=0
 
virtual void AddConnectionAcquiredHandler (ConnectionAcquiredEvent::Handler &handler)=0
 
virtual void AddServerAcceptanceReceivedHandler (ServerAcceptanceReceivedEvent::Handler &handler)=0
 
virtual void AddNetworkInitHandler (NetworkInitEvent::Handler &handler)=0
 
virtual void AddSessionInitHandler (SessionInitEvent::Handler &handler)=0
 
virtual void AddSessionShutdownHandler (SessionShutdownEvent::Handler &handler)=0
 
virtual void AddLevelLoadBlockedHandler (LevelLoadBlockedEvent::Handler &handler)=0
 
virtual void AddNoServerLevelLoadedHandler (NoServerLevelLoadedEvent::Handler &handler)=0
 
virtual void AddVersionMismatchHandler (VersionMismatchEvent::Handler &handler)=0
 
virtual void SendNotifyClientMigrationEvent (AzNetworking::ConnectionId connectionId, const HostId &hostId, uint64_t userIdentifier, ClientInputId lastClientInputId, NetEntityId controlledEntityId)=0
 
virtual void SendNotifyEntityMigrationEvent (const ConstNetworkEntityHandle &entityHandle, const HostId &remoteHostId)=0
 
virtual void SendReadyForEntityUpdates (bool readyForEntityUpdates)=0
 
virtual AZ::TimeMs GetCurrentHostTimeMs () const =0
 
virtual float GetCurrentBlendFactor () const =0
 
virtual INetworkTimeGetNetworkTime ()=0
 
virtual INetworkEntityManagerGetNetworkEntityManager ()=0
 
virtual void RegisterPlayerIdentifierForRejoin (uint64_t temporaryUserIdentifier, NetEntityId controlledEntityId)=0
 
virtual void CompleteClientMigration (uint64_t temporaryUserIdentifier, AzNetworking::ConnectionId connectionId, const HostId &publicHostId, ClientInputId migratedClientInputId)=0
 
virtual void SetShouldSpawnNetworkEntities (bool value)=0
 
virtual bool GetShouldSpawnNetworkEntities () const =0
 
MultiplayerStatsGetStats ()
 

Static Public Attributes

static const uint16_t UseDefaultHostPort = 0
 

Detailed Description

IMultiplayer provides insight into the Multiplayer session and its Agents.

IMultiplayer is an AZ::Interface<T> that provides applications access to multiplayer session information and events. IMultiplayer is implemented on the MultiplayerSystemComponent and is used to define and access information about the type of session and the role held by the current agent. An Agent is defined here as an actor in a session. Types of Agents included by default are a Client, a Client Server and a Dedicated Server.

IMultiplayer also provides events to allow developers to receive and respond to notifications relating to the session. These include Session Init and Shutdown and on acquisition of a new connection. These events are only fired on Client Server or Dedicated Server. These events are useful for services that talk to matchmaking services that may run in an entirely different layer which may need insight to the gameplay session.

Member Function Documentation

◆ AddClientMigrationEndEventHandler()

virtual void Multiplayer::IMultiplayer::AddClientMigrationEndEventHandler ( ClientMigrationEndEvent::Handler &  handler)
pure virtual

Adds a ClientMigrationEndEvent Handler which is invoked when a client completes migration.

Parameters
handlerThe ClientMigrationEndEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddClientMigrationStartEventHandler()

virtual void Multiplayer::IMultiplayer::AddClientMigrationStartEventHandler ( ClientMigrationStartEvent::Handler &  handler)
pure virtual

Adds a ClientMigrationStartEvent Handler which is invoked at the start of a client migration.

Parameters
handlerThe ClientMigrationStartEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddConnectionAcquiredHandler()

virtual void Multiplayer::IMultiplayer::AddConnectionAcquiredHandler ( ConnectionAcquiredEvent::Handler &  handler)
pure virtual

Adds a ConnectionAcquiredEvent Handler which is invoked when a new endpoint connects to the session.

Parameters
handlerThe ConnectionAcquiredEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddEndpointDisconnectedHandler()

virtual void Multiplayer::IMultiplayer::AddEndpointDisconnectedHandler ( EndpointDisconnectedEvent::Handler &  handler)
pure virtual

Adds a EndpointDisconnectedEvent Handler which is invoked on the client when a disconnection occurs.

Parameters
handlerThe EndpointDisconnectedEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddLevelLoadBlockedHandler()

virtual void Multiplayer::IMultiplayer::AddLevelLoadBlockedHandler ( LevelLoadBlockedEvent::Handler &  handler)
pure virtual

Adds a LevelLoadBlockedEvent Handler which is invoked whenever the multiplayer system blocks a level load.

Parameters
handlerThe LevelLoadBlockedEvent handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddNetworkInitHandler()

virtual void Multiplayer::IMultiplayer::AddNetworkInitHandler ( NetworkInitEvent::Handler &  handler)
pure virtual

Adds a NetworkInitEvent Handler which is invoked when the network is initialized on the dedicated server or client-server.

Parameters
handlerThe NetworkInitEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddNoServerLevelLoadedHandler()

virtual void Multiplayer::IMultiplayer::AddNoServerLevelLoadedHandler ( NoServerLevelLoadedEvent::Handler &  handler)
pure virtual

Adds a NoServerLevelLoadedEvent Handler which is invoked whenever a client connects to a server that doesn't have any level loaded.

Parameters
handlerThe NoServerLevelLoadedEvent handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddNotifyClientMigrationHandler()

virtual void Multiplayer::IMultiplayer::AddNotifyClientMigrationHandler ( NotifyClientMigrationEvent::Handler &  handler)
pure virtual

Adds a NotifyClientMigrationEvent Handler which is invoked when a client migrates from one host to another.

Parameters
handlerThe NotifyClientMigrationEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddNotifyEntityMigrationEventHandler()

virtual void Multiplayer::IMultiplayer::AddNotifyEntityMigrationEventHandler ( NotifyEntityMigrationEvent::Handler &  handler)
pure virtual

Adds a NotifyEntityMigrationEvent Handler which is invoked when an entity migrates from one host to another.

Parameters
handlerThe NotifyEntityMigrationEvent Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddServerAcceptanceReceivedHandler()

virtual void Multiplayer::IMultiplayer::AddServerAcceptanceReceivedHandler ( ServerAcceptanceReceivedEvent::Handler &  handler)
pure virtual

Adds a ServerAcceptanceReceived Handler which is invoked when the client receives the accept packet from the server.

Parameters
handlerThe ServerAcceptanceReceived Handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddSessionInitHandler()

virtual void Multiplayer::IMultiplayer::AddSessionInitHandler ( SessionInitEvent::Handler &  handler)
pure virtual
Deprecated:
If looking for an event when a multiplayer session is created, use SessionNotificationBus::OnCreateSessionBegin or SessionNotificationBus::OnCreateSessionEnd

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddSessionShutdownHandler()

virtual void Multiplayer::IMultiplayer::AddSessionShutdownHandler ( SessionShutdownEvent::Handler &  handler)
pure virtual
Deprecated:
If looking for an event when a multiplayer session ends, use SessionNotificationBus::OnDestroySessionBegin or SessionNotificationBus::OnDestroySessionEnd.

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ AddVersionMismatchHandler()

virtual void Multiplayer::IMultiplayer::AddVersionMismatchHandler ( VersionMismatchEvent::Handler &  handler)
pure virtual

Adds a VersionMismatchEvent Handler which is invoked whenever two multiplayer endpoints have a version mismatch. For example, the provided handler will be triggered if a client tries connecting to a server that's using a different multiplayer version.

Parameters
handlerThe VersionMismatchEvent handler to add

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ CompleteClientMigration()

virtual void Multiplayer::IMultiplayer::CompleteClientMigration ( uint64_t  temporaryUserIdentifier,
AzNetworking::ConnectionId  connectionId,
const HostId &  publicHostId,
ClientInputId  migratedClientInputId 
)
pure virtual

Completes a client migration event by informing the appropriate client to migrate between hosts.

Parameters
temporaryUserIdentifierthe temporary user identifier used to identify a player across hosts
connectionIdthe connection id of the player being migrated
publicHostIdthe public address of the new host the client should connect to
migratedClientInputIdthe last clientInputId processed prior to migration

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ Connect()

virtual bool Multiplayer::IMultiplayer::Connect ( const AZStd::string &  remoteAddress,
uint16_t  port 
)
pure virtual

Connects to the specified IP as a Client.

Parameters
remoteAddressThe domain or IP to connect to
portThe port to connect to
Returns
if a connection was successfully created

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetAgentType()

virtual MultiplayerAgentType Multiplayer::IMultiplayer::GetAgentType ( ) const
pure virtual

Gets the type of Agent this IMultiplayer impl represents.

Returns
The type of agents represented

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetCurrentBlendFactor()

virtual float Multiplayer::IMultiplayer::GetCurrentBlendFactor ( ) const
pure virtual

Returns the current blend factor for client side interpolation. This value is only relevant on the client and is used to smooth between host frames

Returns
the current blend factor

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetCurrentHostTimeMs()

virtual AZ::TimeMs Multiplayer::IMultiplayer::GetCurrentHostTimeMs ( ) const
pure virtual

Returns the current server time in milliseconds. This can be one of three possible values:

  1. On the host outside of rewind scope, this will return the latest application elapsed time in ms.
  2. On the host within rewind scope, this will return the rewound time in ms.
  3. On the client, this will return the most recently replicated server time in ms.
    Returns
    the current server time in milliseconds

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetNetworkEntityManager()

virtual INetworkEntityManager * Multiplayer::IMultiplayer::GetNetworkEntityManager ( )
pure virtual

Returns the network entity manager instance bound to this multiplayer instance.

Returns
pointer to the network entity manager instance bound to this multiplayer instance

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetNetworkTime()

virtual INetworkTime * Multiplayer::IMultiplayer::GetNetworkTime ( )
pure virtual

Returns the network time instance bound to this multiplayer instance.

Returns
pointer to the network time instance bound to this multiplayer instance

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetShouldSpawnNetworkEntities()

virtual bool Multiplayer::IMultiplayer::GetShouldSpawnNetworkEntities ( ) const
pure virtual

Retrieves the current network entity instantiation behaviour.

Returns
boolean true if netbound entities should be auto instantiated, false if not

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ GetStats()

MultiplayerStats & Multiplayer::IMultiplayer::GetStats ( )
inline

Retrieve the stats object bound to this multiplayer instance.

Returns
the stats object bound to this multiplayer instance

◆ InitializeMultiplayer()

virtual void Multiplayer::IMultiplayer::InitializeMultiplayer ( MultiplayerAgentType  state)
pure virtual

Sets the type of this Multiplayer connection and calls any related callback.

Parameters
stateThe state of this connection

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ RegisterPlayerIdentifierForRejoin()

virtual void Multiplayer::IMultiplayer::RegisterPlayerIdentifierForRejoin ( uint64_t  temporaryUserIdentifier,
NetEntityId  controlledEntityId 
)
pure virtual

Registers a temp userId to allow a host to look up a players controlled entity in the event of a rejoin or migration event.

Parameters
temporaryUserIdentifierthe temporary user identifier used to identify a player across hosts
controlledEntityIdthe controlled entityId of the players autonomous entity

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ SendNotifyClientMigrationEvent()

virtual void Multiplayer::IMultiplayer::SendNotifyClientMigrationEvent ( AzNetworking::ConnectionId  connectionId,
const HostId &  hostId,
uint64_t  userIdentifier,
ClientInputId  lastClientInputId,
NetEntityId  controlledEntityId 
)
pure virtual

Signals a NotifyClientMigrationEvent with the provided parameters.

Parameters
connectionIdthe connection id of the client that is migrating
hostIdthe host id of the host the client is migrating to
userIdentifierthe user identifier the client will provide the new host to validate identity
lastClientInputIdthe last processed clientInputId by the current host
controlledEntityIdthe entityId of the clients autonomous entity

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ SendNotifyEntityMigrationEvent()

virtual void Multiplayer::IMultiplayer::SendNotifyEntityMigrationEvent ( const ConstNetworkEntityHandle entityHandle,
const HostId &  remoteHostId 
)
pure virtual

Signals a NotifyEntityMigrationEvent with the provided parameters.

Parameters
entityHandlethe network entity handle of the entity being migrated
remoteHostIdthe host id of the host the entity is migrating to

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ SendReadyForEntityUpdates()

virtual void Multiplayer::IMultiplayer::SendReadyForEntityUpdates ( bool  readyForEntityUpdates)
pure virtual

Sends a packet telling if entity update messages can be sent.

Parameters
readyForEntityUpdatesReady for entity updates or not

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ SetShouldSpawnNetworkEntities()

virtual void Multiplayer::IMultiplayer::SetShouldSpawnNetworkEntities ( bool  value)
pure virtual

Enables or disables automatic instantiation of netbound entities. This setting is controlled by the networking layer and should not be touched If enabled, netbound entities will instantiate as spawnables are loaded into the game world, generally true for the server If disabled, netbound entities will only stream from a host, always true for a client

Parameters
valueboolean value controlling netbound entity instantiation behaviour

Implemented in Multiplayer::MultiplayerSystemComponent.

◆ Terminate()

virtual void Multiplayer::IMultiplayer::Terminate ( AzNetworking::DisconnectReason  reason)
pure virtual
Parameters
reasonThe reason for terminating connections

Implemented in Multiplayer::MultiplayerSystemComponent.

Member Data Documentation

◆ UseDefaultHostPort

const uint16_t Multiplayer::IMultiplayer::UseDefaultHostPort = 0
static

Starts hosting a server.

Parameters
portThe port to listen for connection on, 0 means use the currently configured port value of sv_port
isDedicatedWhether the server is dedicated or client hosted
Returns
if the application successfully started hosting

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