InworldClient
Module: Inworld.AI. Namespace: Inworld. Inherited from: MonoBehavior
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. |
Auto Scene | If checked, we'll automatically find the first scene containing the characters. |
Max Waiting List Size | Sets the max size of the cached outgoing packets. 100 by default. |
Continuation | For the new Session Continuation state to load. |
Enable Group Chat | Checked to enable group chat (Need studio feature enabled first.) |
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. |
Game Session ID | The string for saving the game session by deverlopers. |
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 |
---|---|
Current | Gets the current LiveInfo. |
LiveSessionData | Gets the live session data. Key by character's Character ID (aka brainName) value by its agent ID. |
EnableGroupChat | Gets if group chat is enabled. This feature is still under development. If you'd like to test it, please contact support@inworld.ai. |
SessionHistory | Get/Set the session history. |
AutoSceneSearch | Get/Set if the client will automatically search for a scene for the selected characters. By default it's disabled. |
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 character's full name. | "characterFullName": the request characters' Brain ID. |
GetCharacterDataByFullNames | Get the InworldCharacterData by characters' full name. | "characterFullNames": the list of the characters' Brain ID. |
GetCharacterDataByID | Gets the InworldCharacterData corresponding to the given agentID. Usually used when processing packets, but don't know it's sender/receiver of characters. | 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. | loadHistory: check if you're trying to load the history. gameSessionID: Add your customized gameSessionID for better user data control. |
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. |
SendSessionConfig | Send Session Config to Inworld Server. Including capabilities, game session info, client info, user info, etc. | loadHistory: check if you'd like to load the history. gameSessionID: add your customized game session ID for better user control. |
SendCapabilities | Send Capabilities to Inworld Server. Obsoleted. Use SendSessionConfig instead. | |
SendClientConfig | Send Client Config to Inworld Server. Obsoleted. Use SendSessionConfig instead. | |
SendUserConfig | Send User Config to Inworld Server. Obsoleted. Use SendSessionConfig instead. | |
SendHistory | Send the previous dialog (New version) to specific scene. Obsoleted. Use SendSessionConfig instead. | |
SendTextTo | New Send messages to an InworldCharacter in this current scene. NOTE: New method uses brain ID (aka character's full name) instead of live session ID. | textToSend:the message to send. brainName:the full name of the InworldCharacter. If not set, it'll broadcast to the current chat group. immediate: check if this packet needs to send immediately without order (Need to make sure client is connected first). |
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. |
SendNarrativeActionTo | New Send narrative action 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 (Would be implemented in future). | narrativeAction: the narrative action to send. brainName: the list of the characters full name. immediate: if this packet needs to send immediately without order (Need to make sure client is connected first). |
SendNarrativeAction | Legacy Send a narrative action to an InworldCharacter in this current scene. | characterID: the live session ID of the character to send. narrativeAction: the narrative action 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. brainName: the full name of the characters in the scene. immediate: if this packet needs to send immediately without order. By default it's true (Need to make sure client is connected first). |
SendCancelEvent | Legacy Send the CancelResponse Event to InworldServer 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. |
SendRegenerateEvent | Immediately send regenerate response to the specific interaction. | characterID: The live session ID of the character. interactionID: the interaction you'd like to regenerate. |
SendApplyResponseEvent | Select a packet from all the responses to continue conversation. Call it only if you have multiple responses based on the current interaction. | characterID: The live session ID of the character. regenResponsePid: The packet ID that you want to continue. |
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. brainName: the full name of the characters in the scene. immediate: if this packet needs to send immediately without order. By default it's true (Need to make sure client is connected first). |
SendTrigger | Legacy Send the 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. | "brainName: the full name of the characters to send. micMode: If you'd like to enable the character interrupt you, check this option to OPEN_MIC. immediate: If sending immediately (need to make sure client has connected). |
StartAudio | Legacy 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. micMode: If you'd like to enable the character interrupt you, check this option to OPEN_MIC. |
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. | immediate: If immediately send message (needs connected to server first). |
StopAudio | Legacy 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. brainName: the character's full name. immediate: if you want to send the data immediately (Need connected first). |
SendAudio | Legacy Send the wav data to server to a specific character. 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. |
UpdateConversation | Update the chat group information to server. If you're sending packets without specific character, it'll be sent to the entire chat group as broadcasting. | conversationID: The customized conversationID if you'd like to specify. brainNames: The list of the full names of the characters. |