Class CoherenceClientConnection
This class is a base of a connection object used to mark an in-game presence and to send 'client messages'. To use the connection system:
* Create a prefab that has a CoherenceSync attached to it. This prefab must reside in the 'Resources' directory.
* Link prefab to the CoherenceBridge.ClientConnectionPrefab field.
* (Optionally) You can use the ClientConnections's ProvidePrefab event for a fine grained control over objects instantiated for each connection.
* Make sure that the Coherencebridge.GlobalQueryOn is ticked.
The linked prefab will be instantiated for every new client connection. Since connection uses the global query those objects will be visible regardless of the in-simulation distance between the clients.
public class CoherenceClientConnection
- Inheritance
-
CoherenceClientConnection
Remarks
To get your or other connections you can use methods and properties from the ClientConnections.
Properties
ClientId
Unique ClientID assigned by the server.
public ClientID ClientId { get; }
Property Value
CoherenceBridge
CoherenceBridge that manages this connection.
public ICoherenceBridge CoherenceBridge { get; }
Property Value
EntityId
EntityID of the connection object CoherenceSync.
public Entity EntityId { get; }
Property Value
GameObject
Associated UnityEngine.GameObject or null if no connection prefab was provided.
public GameObject GameObject { get; }
Property Value
- GameObject
IsMyConnection
True if this CoherenceClientConnection belongs to the local client.
public bool IsMyConnection { get; }
Property Value
NetworkEntity
public NetworkEntityState NetworkEntity { get; }
Property Value
Sync
Associated CoherenceSync object or null if no connection prefab was provided.
public CoherenceSync Sync { get; }
Property Value
Type
Coherence connection type (e.g. client, simulator).
public ConnectionType Type { get; }
Property Value
Methods
SendClientMessage(Type, string, ClientID, MessageTarget, params object[])
Sends a client message to the connection whose ClientId matches the
clientId
.
public bool SendClientMessage(Type targetType, string methodName, ClientID clientID, MessageTarget target, params object[] args)
Parameters
targetType
TypemethodName
stringclientID
ClientIDtarget
MessageTargetargs
object[]
Returns
- bool
False if connection for a given
clientId
was not found, has no associated CoherenceSync, or if sending has failed.
SendClientMessage(Type, string, Entity, MessageTarget, params object[])
Sends a client message to the connection whose EntityId matches the
entityId
.
public bool SendClientMessage(Type targetType, string methodName, Entity entityID, MessageTarget target, params object[] args)
Parameters
targetType
TypemethodName
stringentityID
Entitytarget
MessageTargetargs
object[]
Returns
- bool
False if connection for a given
entityId
was not found, has no associated CoherenceSync, or if sending has failed.
SendClientMessage(Type, string, MessageTarget, params object[])
Sends a client message to the owner of this connection.
public bool SendClientMessage(Type targetType, string methodName, MessageTarget target, params object[] args)
Parameters
targetType
TypemethodName
stringtarget
MessageTargetargs
object[]
Returns
- bool
False if connection has no associated CoherenceSync, or if sending has failed.
SendClientMessage<TTarget>(string, ClientID, MessageTarget, params object[])
public bool SendClientMessage<TTarget>(string methodName, ClientID clientID, MessageTarget target, params object[] args) where TTarget : Component
Parameters
methodName
stringclientID
ClientIDtarget
MessageTargetargs
object[]
Returns
Type Parameters
TTarget
Type of the component that should receive this message.
SendClientMessage<TTarget>(string, Entity, MessageTarget, params object[])
Sends a client message to the connection whose EntityId matches the
entityId
.
public bool SendClientMessage<TTarget>(string methodName, Entity entityID, MessageTarget target, params object[] args) where TTarget : Component
Parameters
methodName
stringentityID
Entitytarget
MessageTargetargs
object[]
Returns
- bool
False if connection for a given
entityId
was not found, has no associated CoherenceSync, or if sending has failed.
Type Parameters
TTarget
Type of the component that should receive this message.
SendClientMessage<TTarget>(string, MessageTarget, params object[])
Sends a client message to the owner of this connection.
public bool SendClientMessage<TTarget>(string methodName, MessageTarget target, params object[] args) where TTarget : Component
Parameters
methodName
stringtarget
MessageTargetargs
object[]
Returns
- bool
False if connection has no associated CoherenceSync, or if sending has failed.
Type Parameters
TTarget
Type of the component that should receive this message.