Watson Developer Cloud Unity SDK  1.0.0
The Unity SDK uses the Watson Developer Cloud services, a collection of REST APIs and SDKs that use cognitive computing to solve complex problems.
IBM.Watson.DeveloperCloud.Connection.WSConnector Class Reference

WebSocket connector class. More...

Classes

class  BinaryMessage
 BinaryMessage for sending raw binary data. More...
 
class  Message
 The base abstract class for a Message that can be sent/received by this class. More...
 
class  TextMessage
 TextMessage is used for sending text messages (e.g. JSON, XML) More...
 

Public Types

enum  ConnectionState { ConnectionState.CONNECTING, ConnectionState.CONNECTED, ConnectionState.DISCONNECTED, ConnectionState.CLOSED }
 ConnectionState enumeration describes the current state of this connector. More...
 

Public Member Functions

delegate void ConnectorEvent (WSConnector connection)
 Callback for a connector event. More...
 
delegate void MessageEvent (Message resp)
 Callback for a message received on the connector. More...
 
void Send (Message msg, bool queue=false)
 This function sends the given message object. More...
 
void Close ()
 This closes this connector, it will block until the send thread exits. More...
 

Static Public Member Functions

static string FixupURL (string URL)
 Helper function to convert a HTTP/HTTPS url into a WS/WSS URL. More...
 
static WSConnector CreateConnector (Credentials credentials, string url, string function, string args)
 Create a WSConnector for the given service and function. More...
 

Properties

ConnectorEvent OnClose [get, set]
 This delegate is invoked when the connection is closed. More...
 
MessageEvent OnMessage [get, set]
 This delegate is invoked when a message is received for a socket. More...
 
string URL [get, set]
 The URL of the WebSocket. More...
 
Dictionary< string, string > Headers [get, set]
 Headers to pass when making the socket. More...
 
Credentials Authentication [get, set]
 Credentials used to authenticate with the server. More...
 
ConnectionState State [get, set]
 The current state of this connector. More...
 

Detailed Description

WebSocket connector class.

Member Enumeration Documentation

ConnectionState enumeration describes the current state of this connector.

Enumerator
CONNECTING 

We are trying to connect.

CONNECTED 

Connector is connected to the server.

DISCONNECTED 

Connected has lost connection to the server.

CLOSED 

Connected has been closed to the server.

Member Function Documentation

void IBM.Watson.DeveloperCloud.Connection.WSConnector.Close ( )
inline

This closes this connector, it will block until the send thread exits.

delegate void IBM.Watson.DeveloperCloud.Connection.WSConnector.ConnectorEvent ( WSConnector  connection)

Callback for a connector event.

Parameters
connectionThe WSConnector object.
static WSConnector IBM.Watson.DeveloperCloud.Connection.WSConnector.CreateConnector ( Credentials  credentials,
string  url,
string  function,
string  args 
)
inlinestatic

Create a WSConnector for the given service and function.

Parameters
serviceIDThe ID of the service.
functionThe name of the function to connect.
argsAdditional function arguments.
Returns
The WSConnector object or null or error.
static string IBM.Watson.DeveloperCloud.Connection.WSConnector.FixupURL ( string  URL)
inlinestatic

Helper function to convert a HTTP/HTTPS url into a WS/WSS URL.

Parameters
URLThe URL to fix up.
Returns
The fixed up URL.
delegate void IBM.Watson.DeveloperCloud.Connection.WSConnector.MessageEvent ( Message  resp)

Callback for a message received on the connector.

Parameters
respThe message object.
void IBM.Watson.DeveloperCloud.Connection.WSConnector.Send ( Message  msg,
bool  queue = false 
)
inline

This function sends the given message object.

Parameters
msgThis is either a BinaryMessage or TextMessage object.
queueIf true, then this function will not signal or start the sending thread.

Property Documentation

Credentials IBM.Watson.DeveloperCloud.Connection.WSConnector.Authentication
getset

Credentials used to authenticate with the server.

Dictionary<string, string> IBM.Watson.DeveloperCloud.Connection.WSConnector.Headers
getset

Headers to pass when making the socket.

ConnectorEvent IBM.Watson.DeveloperCloud.Connection.WSConnector.OnClose
getset

This delegate is invoked when the connection is closed.

MessageEvent IBM.Watson.DeveloperCloud.Connection.WSConnector.OnMessage
getset

This delegate is invoked when a message is received for a socket.

ConnectionState IBM.Watson.DeveloperCloud.Connection.WSConnector.State
getset

The current state of this connector.

string IBM.Watson.DeveloperCloud.Connection.WSConnector.URL
getset

The URL of the WebSocket.


The documentation for this class was generated from the following file: