Class: Streamdata


new Streamdata() sdk provides a way to connect to a remote server and monitor the connection state.

A singleton instance is provided as a streamdataio global variable and gives access to the entire SDK API.

Connecting is achieved with the call to streamdataio.createEventSource(url). This method returns a StreamdataEventSource object which handles connection to the remote server, and provides mechanism to monitor the connection state.


createEventSource(url, token, headers, authStrategy) → {StreamDataEventSource}

Create a new instance of the StreamDataEventSource prototype.

The StreamDataEventSource is the main entry point for establishing Server Sent Event connection to a targeted JSON REST service URL.

Name Type Description
url String Mandatory. The targeted REST URL is formatted as follow:
token String Mandatory. The application token to authentify the request
headers Array Optional. Any specific headers that have to be added to the request. It must be an array with the following structure:['Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==']
authStrategy Object Optional. An object which will enable HMAC signature of the request. You can create this object as follow:

// setup headers
var headers = [];
// setup signatureStrategy
var signatureStrategy = AuthStrategy.newSignatureStrategy('NmEtYTljN2UtYmM1MGZlMGRiNGFQzYS00MGRkLTkNTZlMDY1','NTEtMTQxNiWIzMDEC00OWNlLThmNGYtY2ExMDJxO00NzNhLTgtZWY0MjOTc2YmUxODFiZDU1NmU0ZDAtYWU5NjYxMGYzNDdi');
// instantiate an eventSource
var eventSource = streamdataio.createEventSource('','NmEtYTljN2UtYmM1MGZlMGRiNGFQzYS00MGRkLTkNTZlMDY1',headers,signatureStrategy);