# AgentPublic

Kind: Class · Namespace: Sansar.Simulation · Assembly: Sansar.Simulation.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Simulation">Namespace <a href="/scripting/api/sansar.simulation"><code>Sansar.Simulation</code></a></span>
<span>Inherits <a href="/scripting/api/sansar.script/instanceinterface">Sansar.Script.InstanceInterface</a></span>
</div>

<span id="T:Sansar.Simulation.AgentPublic"></span>

The AgentPublic class is a more limited subset of the [`AgentPrivate`](/scripting/api/sansar.simulation/agentprivate) API for use by other scripts in the scene.

```csharp
public class AgentPublic : Sansar.Script.InstanceInterface
```

## Remarks

AgentPublic has a more limited API than [`AgentPrivate`](/scripting/api/sansar.simulation/agentprivate). Agents may leave the scene at any time. Attempting to use an AgentPublic interface for an agent no longer in the scene will throw a NullReferenceException.

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [AgentInfo](#agentinfo) |
| **Methods** | [SendChat](#sendchat) · [ToString](#tostring) |

## Properties

### AgentInfo

<div class="api-card">
<span id="P:Sansar.Simulation.AgentPublic.AgentInfo"></span>

```csharp signature
public AgentInfo AgentInfo { get; }
```

Returns the [`AgentInfo`](/scripting/api/sansar.simulation/agentinfo) for this instance.

**Value:** [AgentInfo](/scripting/api/sansar.simulation/agentinfo) — The [`AgentInfo`](/scripting/api/sansar.simulation/agentinfo) for this instance

<details class="api-remarks"><summary>Remarks</summary>

The [`AgentInfo`](/scripting/api/sansar.simulation/agentinfo) holds information about an agent.

</details>

</div>


## Methods

### SendChat

<div class="api-card" id="sendchat-string">
<span id="M:Sansar.Simulation.AgentPublic.SendChat(System.String)"></span>

```csharp signature
public void SendChat(string message)
```

Sends a [`String`](https://learn.microsoft.com/dotnet/api/system.string) message to the $className$.

| Parameter | Type | Description |
|---|---|---|
| `message` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The message to send. |

**Throws** [`NullReferenceException`](https://learn.microsoft.com/dotnet/api/system.nullreferenceexception): If the user is no longer online.

**Throws** [`ThrottleException`](/scripting/api/sansar.script/throttleexception): If the throttle rate is exceeded.

<details class="api-remarks"><summary>Remarks</summary>

eprecated. Use AgentPrivate.SendChat or AgentPublic.SendChat

</details>

</div>

<div class="api-card" id="sendchat-string-action">
<span id="M:Sansar.Simulation.AgentPublic.SendChat(System.String,System.Action{Sansar.Script.OperationCompleteEvent})"></span>

```csharp signature
public void SendChat(
    string message,
    Action<Sansar.Script.OperationCompleteEvent> handler
)
```

Sends a [`String`](https://learn.microsoft.com/dotnet/api/system.string) message to the AgentPublic.

| Parameter | Type | Description |
|---|---|---|
| `message` | [string](https://learn.microsoft.com/dotnet/api/system.string) | The message to send. |
| `handler` | [Action&lt;Sansar.Script.OperationCompleteEvent&gt;](https://learn.microsoft.com/dotnet/api/system.action-1) | Handler to be called when the event completes. |

<details class="api-remarks"><summary>Remarks</summary>

Messages may be throttled and ignored.

</details>

</div>

### ToString

<div class="api-card">
<span id="M:Sansar.Simulation.AgentPublic.ToString"></span>
<span id="M:Sansar.Simulation.AgentPublic.ToString()"></span>

```csharp signature
public override string ToString()
```

A string representation of this object.

**Returns:** [string](https://learn.microsoft.com/dotnet/api/system.string) — A string representation of this object.

<details class="api-remarks"><summary>Remarks</summary>

The format of this string may change between releases.

</details>

</div>




<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>