Table of Contents

Class CoherenceClientConnection

Namespace
Coherence.Toolkit
Assembly
Coherence.Toolkit.dll

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

ClientID

CoherenceBridge

CoherenceBridge that manages this connection.

public CoherenceBridge CoherenceBridge { get; }

Property Value

CoherenceBridge

EntityId

EntityID of the connection object CoherenceSync.

public SerializeEntityID EntityId { get; }

Property Value

SerializeEntityID

GameObject

Associated 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

bool

NetworkEntity

public NetworkEntityState NetworkEntity { get; }

Property Value

NetworkEntityState

Sync

Associated CoherenceSync object or null if no connection prefab was provided.

public CoherenceSync Sync { get; }

Property Value

CoherenceSync

Type

Coherence connection type (e.g. client, simulator).

public ConnectionType Type { get; }

Property Value

ConnectionType

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 Type
methodName string
clientID ClientID
target MessageTarget
args 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, SerializeEntityID, MessageTarget, params object[])

Sends a client message to the connection whose EntityId matches the entityId.

public bool SendClientMessage(Type targetType, string methodName, SerializeEntityID entityID, MessageTarget target, params object[] args)

Parameters

targetType Type
methodName string
entityID SerializeEntityID
target MessageTarget
args 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 Type
methodName string
target MessageTarget
args 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 string
clientID ClientID
target MessageTarget
args object[]

Returns

bool

Type Parameters

TTarget

Type of the component that should receive this message.

SendClientMessage<TTarget>(string, SerializeEntityID, MessageTarget, params object[])

Sends a client message to the connection whose EntityId matches the entityId.

public bool SendClientMessage<TTarget>(string methodName, SerializeEntityID entityID, MessageTarget target, params object[] args) where TTarget : Component

Parameters

methodName string
entityID SerializeEntityID
target MessageTarget
args 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 string
target MessageTarget
args 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.