Skip to content

Get Sansar

Script API

Chat

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

The Chat class handles chat subscriptions and sending messages to users and other scripts.

public class Chat : Sansar.Script.InstanceInterface

Members at a glance

KindMembers
FieldsAllChannels · DefaultChannel · Script · Server · User
MethodsMessageAllUsers · MessageScript · Subscribe

Fields

AllChannels

Deprecated
[System.Obsolete("All channel subscription no longer allowed", false)] public static readonly int AllChannels

Use as the channel argument for Chat.Subscribe to subscribe to all channels.

Remarks

No longer in use, now the same behavior as DefaultChannel

DefaultChannel

public static readonly int DefaultChannel

Use as the channel argument for Chat.Subscribe to subscribe to the default channel

Script

public static readonly string Script

Indicates that the chat message originated from a script.

Server

public static readonly string Server

Indicates that the chat message originated from the server.

User

public static readonly string User

Indicates that the chat message originated from a user.

Methods

MessageAllUsers

public void MessageAllUsers(string message)

Send a chat message to every user in the Experience.

ParameterTypeDescription
messagestringThe message to send.
Remarks

Messages may be throttled.

public void MessageAllUsers(     string message,     Action<Sansar.Script.OperationCompleteEvent> handler )

Send a chat message to every user in the Experience.

ParameterTypeDescription
messagestringThe message to send.
handlerAction<Sansar.Script.OperationCompleteEvent>Handler to be called when the event completes.
Remarks

Messages may be throttled.

MessageScript

public void MessageScript(     string message,     Sansar.Script.ScriptId scriptId,     int channel )

Send a string message to a specific script.

ParameterTypeDescription
messagestringThe message to send.
scriptIdSansar.Script.ScriptIdThe id of the script to send the message to.
channelintThe channel to send the message on.
Remarks

Only the script with the matching id will receive the message.

Subscribe

public Sansar.Script.IEventSubscription Subscribe(     Sansar.Script.ScriptId SourceScriptId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     Sansar.Script.SessionId SourceId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     int Channel,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     string Source,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Sourcestringstring source of the chat: system, user or script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     int Channel,     Sansar.Script.ScriptId SourceScriptId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     int Channel,     Sansar.Script.SessionId SourceId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

Deprecated
[System.Obsolete("Use subscription callbacks of type Action<Sansar.Simulation.ChatData>", false)] public void Subscribe(     int Channel,     string Source,     Chat.SubscriptionHandler callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
callbackChat.SubscriptionHandlerCallback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.
public Sansar.Script.IEventSubscription Subscribe(     int Channel,     string Source,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     string Source,     Sansar.Script.ScriptId SourceScriptId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Sourcestringstring source of the chat: system, user or script.
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

public Sansar.Script.IEventSubscription Subscribe(     string Source,     Sansar.Script.SessionId SourceId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Sourcestringstring source of the chat: system, user or script.
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

Deprecated
[System.Obsolete("Use subscription callbacks of type Action<Sansar.Simulation.ChatData>", false)] public void Subscribe(     int Channel,     string Source,     Sansar.Script.ScriptId SourceScriptId,     Chat.SubscriptionHandler callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackChat.SubscriptionHandlerCallback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.
public Sansar.Script.IEventSubscription Subscribe(     int Channel,     string Source,     Sansar.Script.ScriptId SourceScriptId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

Deprecated
[System.Obsolete("Use subscription callbacks of type Action<Sansar.Simulation.ChatData>", false)] public void Subscribe(     int Channel,     string Source,     Sansar.Script.SessionId SourceId,     Chat.SubscriptionHandler callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
callbackChat.SubscriptionHandlerCallback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.
public Sansar.Script.IEventSubscription Subscribe(     int Channel,     string Source,     Sansar.Script.SessionId SourceId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

Deprecated
[System.Obsolete("Use subscription callbacks of type Action<Sansar.Simulation.ChatData>", false)] public void Subscribe(     int Channel,     string Source,     Sansar.Script.SessionId SourceId,     Sansar.Script.ScriptId SourceScriptId,     Chat.SubscriptionHandler callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackChat.SubscriptionHandlerCallback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.
public Sansar.Script.IEventSubscription Subscribe(     int Channel,     string Source,     Sansar.Script.SessionId SourceId,     Sansar.Script.ScriptId SourceScriptId,     Action<ChatData> callback,     bool persistent )

Subscribes to Chat Events.

ParameterTypeDescription
Channelintint channel which the chat occurs on.
Sourcestringstring source of the chat: system, user or script.
SourceIdSansar.Script.SessionIdSansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent.
SourceScriptIdSansar.Script.ScriptIdSansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script.
callbackAction<ChatData>Callback which is executed when the event completes.
persistentboolOptional, set to false to unsubscribe after one event.

Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.

Used in examples

…and 5 more examples in the snapshot.

Generated from the Sansar 47.10.0 client ScriptApi snapshot.