Open 3D Engine Multiplayer Gem API Reference  22.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Public Member Functions | List of all members
Multiplayer::IMultiplayer Class Referenceabstract

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

#include <IMultiplayer.h>

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, 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 AddSessionInitHandler (SessionInitEvent::Handler &handler)=0
 
virtual void AddSessionShutdownHandler (SessionShutdownEvent::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 ()
 

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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ AddSessionInitHandler()

virtual void Multiplayer::IMultiplayer::AddSessionInitHandler ( SessionInitEvent::Handler &  handler)
pure virtual

Adds a SessionInitEvent Handler which is invoked when a new network session starts.

Parameters
handlerThe SessionInitEvent Handler to add

◆ AddSessionShutdownHandler()

virtual void Multiplayer::IMultiplayer::AddSessionShutdownHandler ( SessionShutdownEvent::Handler &  handler)
pure virtual

Adds a SessionShutdownEvent Handler which is invoked when the current network session ends.

Parameters
handlerThe SessionShutdownEvent handler to add

◆ 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

◆ 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

◆ GetAgentType()

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

Gets the type of Agent this IMultiplayer impl represents.

Returns
The type of agents represented

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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

◆ StartHosting()

virtual bool Multiplayer::IMultiplayer::StartHosting ( uint16_t  port,
bool  isDedicated = true 
)
pure virtual

Starts hosting a server.

Parameters
portThe port to listen for connection on
isDedicatedWhether the server is dedicated or client hosted
Returns
if the application successfully started hosting

◆ Terminate()

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

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