Class: Streamdata

Streamdata

new Streamdata()

streamdata.io 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 streamdata.io 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.

Methods

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.

Parameters:
Name Type Description
url String Mandatory. The targeted REST URL is formatted as follow:
protocol://url(:port)(/localpath(?queryparameters))
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('http://myRestservice.com/stocks','NmEtYTljN2UtYmM1MGZlMGRiNGFQzYS00MGRkLTkNTZlMDY1',headers,signatureStrategy);

Returns:
Type
StreamDataEventSource