API reference
API reference
Select your platform
No SDKs available
No versions available

WitWebSocketClient Class

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.

Properties

The settings required to connect, authenticate and drive server/client communication.
The unique id associated with this connection request
Whether the web socket is disconnected, connecting, connected, or disconnecting.
Whether authentication had completed successfully or not
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.
Total amount of failed connection attempts made
The utc time of the last response from the server
A task that will complete once the connection process completes. Response will be true if connected successfully and false otherwise.
IVLogger Logger[Get]

Fields

Whether there currently is data being encoded and/or queued to be sent from the web socket.
Whether there currently is data being received and/or decoded from the web socket.
Whether there currently are any scripts that have called Connect() and not yet requested a Disconnect().
Whether will be reconnecting
The requests currently being tracked by this client. Each access generates a new dictionary and should be cached.

Events

Callback on connection state change.
Callback when subscription state changes for a specific topic id
Callback when a tracked topic generates a request

Member Functions

Constructor with settings data
Constructor that takes in IWitRequestConfiguration and generates default settings use it
Attempts to connect to the specified
Disconnects socket after checking state
Send a request via this client if possible
Send a request via this client if possible
Safely adds a request to the current request list
Safely removes a request from the current request list
Safely removes a request from the current request list by request id
Obtains the current subscription state for a specific topic
Method to subscribe to a specific topic id
Method to unsubscribe to a specific topic id
Method to subscribe to a specific topic id with a parameter to ignore ref count for local unsubscribing following disconnect/error.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon