InworldClient
Module: Inworld.AI. Namespace: Inworld.
This is the base class for sending and receiving data from the server.
Inspector Variables
Variable | Description |
---|---|
Server Config | The current server to which this client is connected. |
Scene Full Name | The full name of the current scene. |
API Key | The API key used to load scenes. Note that if InworldGameData in InworldController has a value, this API Key setting is invalid. |
API Secret | The API Secret used to load scenes. Note that if InworldGameData in InworldController has a value, this API Secret setting is invalid. |
Custom Token | The JSON token string used to load scenes. You can obtain the token from the Inworld Web SDK. |
Public Workspace | The string of the public workspace, used for workspace sharing. |
Auto Scene | If checked, we'll automatically find the first scene containing the characters. |
Continuation | For the new Session Continuation state to load. |
Max Waiting List Size | Sets the max size of the cached outgoing packets. 100 by default. |
Events
Event | Description |
---|---|
OnStatusChanged | Triggered when the status of this component changes. |
OnErrorReceived | Triggered when any error received. |
OnPacketSent | Triggered when any InworldPackets are sent. |
OnGlobalPacketReceived | Triggered when the InworldPackets are received with a source of WORLD. |
OnPacketReceived | Triggered when any InworldPackets from the server are received. |
Properties
Property | Description |
---|---|
Server | Gets or sets the current InworldServerConfig to which this client is connected. |
LiveSessionData | Gets the live session data. Key by character's Character ID (aka brainName) value by its agent ID. |
SessionHistory | Get/Set the session history. |
AutoSceneSearch | Get/Set if the client will automatically search for a scene for the selected characters. |
Server | Gets/Sets the current Inworld server this client is connecting. |
Token | Gets or sets the token used to log in to the Runtime server of Inworld. |
CurrentScene | Gets/Sets the current full name of the Inworld scene. |
IsTokenValid | Gets if the current token is valid. |
Status | Gets or sets the current status of the Inworld client. If set, it will invoke the OnStatusChanged events. |
ErrorMessage | Gets or sets the error message. |
Error | Gets/Sets the InworldError. If the error is no retry, it'll also set the status of this client to be error. |
API
Function | Description | Parameters |
---|---|---|
GetCharacterDataByFullName | Get the InworldCharacterData by characters' full name. | "characterFullNames": the request characters' Brain ID. |
GetCharacterDataByID | Gets the InworldCharacterData corresponding to the given agentID. | agentID: target ID to search. |
GetSceneNameByCharacter | Gets the scene name by the given target characters. | |
PrepareSession | Prepare the session. If the session is freshly established. Please call this. | |
SendFeedbackAsync | Send Feedback data to server. | interactionID: The feedback bubble's interactionID correlationID:The feedback bubble's correlationID feedback: The actual feedback content. |
GetHistoryAsync | Get the session history data. Stored at property SessionHistory. By default, it'll be stored in the memory only, Please store it to your local storage for future use. | sceneFullName: the full name of the target scene. |
SendPackets | A generalized function to send packets. Will automatically be called in outgoing queue. Can be called directly by API. | |
GetAccessToken | Retrieves the access token. This function should be implemented by the child class. | |
Reconnect | Reconnects the session or starts a new session if the current session is invalid. | |
GetLiveSessionInfo | Retrieves the live session information once the scene is loaded. The returned LoadSceneResponse contains the session ID and all the live session IDs for each InworldCharacter in this InworldScene. | |
InitWithCustomToken | Uses the input JSON string of a token instead of API key/secret to load the scene. This token can be obtained from other applications, such as the InworldWebSDK. | token: the custom token to initialize. |
StartSession | Starts the session using the session ID. | |
Disconnect | Disconnects from the Inworld Server. | |
UnloadScene | Unload curren scene. Make sure to be called before loading another scene. | |
LoadScene | Sends a LoadScene request to the Inworld Server. | sceneFullName: the full string of the scene to load. |
SendCapabilities | Send Capabilities to Inworld Server. It should be sent immediately after session started to enable all the conversations. | |
SendSessionConfig | Send Session Config to Inworld Server. It should be sent right after sending Capabilities. | |
SendClientConfig | Send Client Config to Inworld Server. It should be sent right after sending Session Config. | |
SendUserConfig | Send User Config to Inworld Server. It should be sent right after sending Client Config. | |
SendHistory | Send the previous dialog (New version) to specific scene. Can be supported by either previous state (base64) or previous dialog (actor: text) | |
SendTextTo | New Send messages to an InworldCharacter in this current scene. NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID. 2. New method support broadcasting to multiple characters. | textToSend:the message to send. characters:the list of the characters full name. |
SendText | Sends messages to an InworldCharacter in the current scene. | characterID: the live session ID of the character to send. textToSend: the message to send. |
SendCancelEventTo | New Send the CancelResponse Event to InworldServer to interrupt the character's speaking. NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID 2. New method support broadcasting to multiple characters. | interactionID: the handle of the dialog context that needs to be cancelled. utteranceID:the current utterance ID that needs to be cancelled. characters: the full name of the characters in the scene. |
SendCancelEvent | Sends the CancelResponse Event to the Inworld Server to interrupt the character's speaking. | characterID: the live session ID of the character to send. utteranceID:the current utterance ID that needs to be cancelled. interactionID: the handle of the dialog context that needs to be cancelled. |
SendTriggerTo | New Send the trigger to an InworldCharacter in the current scene. NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID. 2. New method support broadcasting to multiple characters. | triggerName: the name of the trigger to send. parameters: the parameters and their values for the triggers. charactersthe full name of the characters in the scene. |
SendTrigger | Sends a trigger to an InworldCharacter in the current scene. | charID: the live session ID of the character to send. triggerName: the name of the trigger to send. parameters: the parameters and their values for the triggers. |
StartAudioTo | New Send AUDIO_SESSION_START control events to server. NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID 2. New method support broadcasting to multiple characters. | "characters: the full name of the characters to send. |
StartAudio | Sends AUDIO_SESSION_START control events to the server. Without sending this message, all the audio data will be discarded by the server. However, if you send this event twice in a row without sending StopAudio() , the Inworld server will also throw exceptions and terminate the session. | charID: the live session ID of the character to send. |
StopAudioTo | New Send AUDIO_SESSION_END control events to server to. NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID. 2. New method support broadcasting to multiple characters. | characters: the full name of the character to send. |
StopAudio | Sends AUDIO_SESSION_END control events to the server. | charID: the live session ID of the character to send. |
SendAudioTo | New Send the wav data to server to a specific character. Need to make sure that AUDIO_SESSION_START control event has been sent to server. NOTE: 1. New method uses brain ID (aka character's full name) instead of live session ID. 2. New method support broadcasting to multiple characters. Only the base64 string of the wave data is supported by Inworld server. Additionally, the sample rate of the wave data has to be 16000, mono channel. | base64:the base64 string of the wave data to send. characters: the full name of the character to send. |
SendAudio | Sends the WAV data to the server. Ensure that the AUDIO_SESSION_START control event has been sent to the server. Only the base64 string of the wave data is supported by the Inworld server. Additionally, the sample rate of the wave data must be 16000, mono channel. | charID: the live session ID of the character to send. base64: the base64 string of the wave data to send. |
Related Class
InworldWebSocketClient
Module: Inworld.AI. Namespace: Inworld. Inherits from InworldClient
From the version 3.3 and later, as the NDK client is deprecated, all the logic of the InworldWebSocketClient has been merged to InworldClient.