API reference

WitWebSocketClient Class

Extends IDisposable
An class for performing multi-threaded web socket communication to a Wit endpoint WitWebSocketClient is a wrapper for web socket communication that facilitates the safe upload and download of data between the Voice SDK and Wit.ai. The class handles connection, transmission and response handling for all socket communication. Three background threads are spawned by each WitWebSocketClient in order to handle encoding/uploading, downloading/decoding and response handling respectively. WitWebSocketClients contain a list of IWitWebSocketRequests which are used to facilitate upload and download of data. When sending a WitChunk the IWitWebSocketRequest’s request id will also be sent within the json data. When receiving a WitChunk, request id will be checked within the json data and the appropriate IWitWebSocketRequest will handle the response. If no matching request is found, the WitChunk’s topic id will be used to find the appropriate IWitWebSocketSubscriber which then will generate a request to handle the response.

Constructors

WitWebSocketClient ( settings )
Constructor with settings data
Signature
Meta.Voice.Net.WebSockets.WitWebSocketClient.WitWebSocketClient(WitWebSocketSettings settings)
Parameters
WitWebSocketClient ( configuration )
Constructor that takes in IWitRequestConfiguration and generates default settings use it
Signature
Meta.Voice.Net.WebSockets.WitWebSocketClient.WitWebSocketClient(IWitRequestConfiguration configuration)
Parameters

Fields

ConnectionRequestId : string
The unique id associated with this connection request
Signature
string Meta.Voice.Net.WebSockets.WitWebSocketClient.ConnectionRequestId
IsDownloading : bool
Whether there currently is data being received and/or decoded from the web socket.
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.IsDownloading
IsReconnecting : bool
Whether will be reconnecting
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.IsReconnecting
IsReferenced : bool
Whether there currently are any scripts that have called Connect() and not yet requested a Disconnect().
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.IsReferenced
IsUploading : bool
Whether there currently is data being encoded and/or queued to be sent from the web socket.
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.IsUploading
The options associated with this connection request
Signature
Meta.WitAi.Configuration.WitRequestOptions Meta.Voice.Net.WebSockets.WitWebSocketClient.Options
Requests : Dictionary< string, IWitWebSocketRequest >
The requests currently being tracked by this client. Each access generates a new dictionary and should be cached.
Signature
Dictionary<string, IWitWebSocketRequest> Meta.Voice.Net.WebSockets.WitWebSocketClient.Requests

Properties

ConnectionCompletion : TaskCompletionSource< bool >
[Get]
A task that will complete once the connection process completes. Response will be true if connected successfully and false otherwise.
Signature
TaskCompletionSource<bool> Meta.Voice.Net.WebSockets.WitWebSocketClient.ConnectionCompletion
ConnectionState : WitWebSocketConnectionState
[Get]
Whether the web socket is disconnected, connecting, connected, or disconnecting.
Signature
WitWebSocketConnectionState Meta.Voice.Net.WebSockets.WitWebSocketClient.ConnectionState
FailedConnectionAttempts : int
[Get]
Total amount of failed connection attempts made
Signature
int Meta.Voice.Net.WebSockets.WitWebSocketClient.FailedConnectionAttempts
IsAuthenticated : bool
[Get]
Whether authentication had completed successfully or not
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.IsAuthenticated
LastResponseTime : DateTime
[Get]
The utc time of the last response from the server
Signature
DateTime Meta.Voice.Net.WebSockets.WitWebSocketClient.LastResponseTime
Logger : IVLogger
[Get]
Signature
IVLogger Meta.Voice.Net.WebSockets.WitWebSocketClient.Logger
OnError : WitErrorEvent
[Get]
Triggered when there was an error in setup or with websocket communications
Signature
WitErrorEvent Meta.Voice.Net.WebSockets.WitWebSocketClient.OnError
ReferenceCount : int
[Get]
Total amount of scripts that have called Connect() and have not yet called Disconnect(). Used to ensure WebSocketClient is only disconnected once no scripts are still referenced.
Signature
int Meta.Voice.Net.WebSockets.WitWebSocketClient.ReferenceCount
[Get]
The settings required to connect, authenticate and drive server/client communication.
Signature
WitWebSocketSettings Meta.Voice.Net.WebSockets.WitWebSocketClient.Settings

Events

OnConnectionStateChanged : Action< WitWebSocketConnectionState >
Callback on connection state change.
Signature
Action<WitWebSocketConnectionState> Meta.Voice.Net.WebSockets.WitWebSocketClient.OnConnectionStateChanged
OnProcessForwardedResponse : WitWebSocketResponseProcessor
An event callback for processing a response for a request originating on a different client with a topic this client has subscribed to.
Signature
WitWebSocketResponseProcessor Meta.Voice.Net.WebSockets.WitWebSocketClient.OnProcessForwardedResponse
OnRequestTracked : Action< WitWebSocketClient, IWitWebSocketRequest >
An event that is called whenever a request begins being tracked by a WitWebSocketClient
Signature
Action<WitWebSocketClient, IWitWebSocketRequest> Meta.Voice.Net.WebSockets.WitWebSocketClient.OnRequestTracked
OnRequestUntracked : Action< WitWebSocketClient, IWitWebSocketRequest >
An event that is called whenever a request stops being tracked by a WitWebSocketClient
Signature
Action<WitWebSocketClient, IWitWebSocketRequest> Meta.Voice.Net.WebSockets.WitWebSocketClient.OnRequestUntracked
OnTopicRequestTracked : Action< string, IWitWebSocketRequest >
Callback when a tracked topic generates a request
Signature
Action<string, IWitWebSocketRequest> Meta.Voice.Net.WebSockets.WitWebSocketClient.OnTopicRequestTracked
OnTopicSubscriptionStateChange : PubSubTopicSubscriptionDelegate
Callback when subscription state changes for a specific topic id
Signature
PubSubTopicSubscriptionDelegate Meta.Voice.Net.WebSockets.WitWebSocketClient.OnTopicSubscriptionStateChange

Methods

Connect ()
Attempts to connect to the specified
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.Connect()
Returns
void
Disconnect ()
Disconnects socket after checking state
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.Disconnect()
Returns
void
Dispose ()
Remove all references
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.Dispose()
Returns
void
ForceDisconnect ()
Forces a disconnect independent from reference count. to reconnect.
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.ForceDisconnect()
Returns
void
GetTopicSubscriptionState ( topicId )
Obtains the current subscription state for a specific topic
Signature
PubSubSubscriptionState Meta.Voice.Net.WebSockets.WitWebSocketClient.GetTopicSubscriptionState(string topicId)
Parameters
topicId: string
SendRequest ( request )
Send a request via this client if possible
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.SendRequest(IWitWebSocketRequest request)
Parameters
Returns
bool
SendRequestAsync ( request )
Send a request via this client if possible
Signature
async Task<string> Meta.Voice.Net.WebSockets.WitWebSocketClient.SendRequestAsync(IWitWebSocketRequest request)
Parameters
Returns
async Task< string >
Subscribe ( topicId )
Method to subscribe to a specific topic id
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.Subscribe(string topicId)
Parameters
topicId: string
Returns
void
TrackRequest ( request )
Safely adds a request to the current request list
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.TrackRequest(IWitWebSocketRequest request)
Parameters
Returns
bool
Unsubscribe ( topicId )
Method to unsubscribe to a specific topic id
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.Unsubscribe(string topicId)
Parameters
topicId: string
Returns
void
Unsubscribe ( topicId , ignoreRefCount )
Method to subscribe to a specific topic id with a parameter to ignore ref count for local unsubscribing following disconnect/error.
Signature
void Meta.Voice.Net.WebSockets.WitWebSocketClient.Unsubscribe(string topicId, bool ignoreRefCount)
Parameters
topicId: string
ignoreRefCount: bool
Returns
void
UntrackRequest ( request )
Safely removes a request from the current request list
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.UntrackRequest(IWitWebSocketRequest request)
Parameters
Returns
bool
UntrackRequest ( requestId )
Safely removes a request from the current request list by request id
Signature
bool Meta.Voice.Net.WebSockets.WitWebSocketClient.UntrackRequest(string requestId)
Parameters
requestId: string
Returns
bool