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 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
CoherenceBridge
CoherenceBridge that manages this connection.
public CoherenceBridge CoherenceBridge { get; }
Property Value
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
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[])
public bool SendClientMessage(Type targetType, string methodName, ClientID clientID, MessageTarget target, params object[] args)
Parameters
targetType
TypemethodName
stringclientID
ClientIDtarget
MessageTargetargs
object[]
Returns
SendClientMessage(Type, string, SerializeEntityID, MessageTarget, params object[])
public bool SendClientMessage(Type targetType, string methodName, SerializeEntityID entityID, MessageTarget target, params object[] args)
Parameters
targetType
TypemethodName
stringentityID
SerializeEntityIDtarget
MessageTargetargs
object[]
Returns
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, SerializeEntityID, MessageTarget, params object[])
public bool SendClientMessage<TTarget>(string methodName, SerializeEntityID entityID, MessageTarget target, params object[] args) where TTarget : Component
Parameters
methodName
stringentityID
SerializeEntityIDtarget
MessageTargetargs
object[]
Returns
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.