The Chat class handles chat subscriptions and sending messages to users and other scripts.
public class Chat : Sansar.Script.InstanceInterfaceMembers at a glance
| Kind | Members |
|---|---|
| Fields | AllChannels · DefaultChannel · Script · Server · User |
| Methods | MessageAllUsers · MessageScript · Subscribe |
Fields
AllChannels
[System.Obsolete("All channel subscription no longer allowed", false)]
public static readonly int AllChannelsUse 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 DefaultChannelUse as the channel argument for Chat.Subscribe to subscribe to the default channel
Script
public static readonly string ScriptIndicates that the chat message originated from a script.
Server
public static readonly string ServerIndicates that the chat message originated from the server.
User
public static readonly string UserIndicates 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.
| Parameter | Type | Description |
|---|---|---|
message | string | The 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.
| Parameter | Type | Description |
|---|---|---|
message | string | The message to send. |
handler | Action<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.
| Parameter | Type | Description |
|---|---|---|
message | string | The message to send. |
scriptId | Sansar.Script.ScriptId | The id of the script to send the message to. |
channel | int | The 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.
| Parameter | Type | Description |
|---|---|---|
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Source | string | string source of the chat: system, user or script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, set to false to unsubscribe after one event. |
Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.
[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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
callback | Chat.SubscriptionHandler | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Source | string | string source of the chat: system, user or script. |
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Source | string | string source of the chat: system, user or script. |
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, set to false to unsubscribe after one event. |
Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.
[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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Chat.SubscriptionHandler | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, set to false to unsubscribe after one event. |
Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.
[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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
callback | Chat.SubscriptionHandler | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, set to false to unsubscribe after one event. |
Returns: Sansar.Script.IEventSubscription — An IEventSubscription that can be used to cancel the subscription.
[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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Chat.SubscriptionHandler | Callback which is executed when the event completes. |
persistent | bool | Optional, 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.
| Parameter | Type | Description |
|---|---|---|
Channel | int | int channel which the chat occurs on. |
Source | string | string source of the chat: system, user or script. |
SourceId | Sansar.Script.SessionId | Sansar.Script.SessionId id of the chat source. May be SessionId.Invalid if the source is not an agent. |
SourceScriptId | Sansar.Script.ScriptId | Sansar.Script.ScriptId id of the chat source. May be ScriptId.Invalid if the source is not a script. |
callback | Action<ChatData> | Callback which is executed when the event completes. |
persistent | bool | Optional, 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
- StatsExample.cs
- VisitorTrackerExample.cs
- BanHammerExample.cs
CameraShakeExample.csColorLutExample.cs- CoroutineEventExample.cs
- CoroutineExample.cs
- GravityExample.cs
- MediaOverrideExample.cs
- MemoryExample.cs
- ObjectScriptExample.cs
- QuestDebugExample.cs
…and 5 more examples in the snapshot.
Generated from the Sansar 47.10.0 client ScriptApi snapshot.