The kony.stream namespace forms the Streaming API and provides the following API elements.
The kony.stream namespace provides the following functions.
This API allows you to deregister the application that was registered earlier with the Streaming Server.
Use Case
Use this API when you want to discontinue an application from streaming the data from a streaming server.
Syntax
kony.stream.deregisterDataStream(streamObject)
Input Parameters
Parameter | Description |
---|---|
streamObject [Object] - Mandatory | Streaming Object that is returned during the registration process. |
Example
deregisterDataStream: function() { //Define config parameters to the register stream. var configParams = { url: "http://localhost:8081/listStreamData", method: "post", outputformat: "JSON" }; //Registers the stream. var streamObj = kony.stream.registerDataStream("http1.1", configParams, "json", this.myCallbackFunctionDeregister); //Deregisters the data stream with the specified identifier on Windows Phone. var status = kony.stream.deregisterDataStream(streamObj); //Reading the status. alert("Status is ::" + status); }
Return Values
None.
Exceptions
Platform Availability
Available on all platforms except Desktop Web and Windows Kiosk*. *Dummy Implementation on Mobile Web.
This API registers the application for streaming with the OS provider of the underlying platform.
Syntax
kony.stream.registerDataStream(protocol,configparams,outputformat,callback)
Input Parameters
Parameter | Description |
---|---|
protocol [String] - Mandatory | Specifies the underlying streaming protocol to be used. Kony currently supports only HTTP1.1 protocol. |
Specifies an Object with key-value pairs of configuration parameters required for the underlying protocol. The following are the configuration parameters for HTTP1.1 protocol:
| |
Specifies the output format of the stream. Currently supported values are:
Note: If JSON is the output format specified, output from the streaming server is converted to an Object and is passed as an input parameter to the callback function. | |
Specifies the function that needs to be executed when the streaming data is available. Note: This function is also executed incase of any network error or system error in listening to the data stream. The callback function has the following signature: callbackFunction(status, data, context)
|
Example
myCallbackFunctionRegister: function(status, data, context) { //Execute the logic here alert("You have successfully registered a streaming service"); },
//Registers the stream. var streamObj = kony.stream.registerDataStream("http1.1", configParams, "json", this.myCallbackFunctionDeregister); //Reading the status. alert("Status is ::" + status); }
Return Values
streamObject [Object]: Stream Object for this registration. This object needs to be used during the de-registration process. It is null when there is any input error for a JavaScript application.
Exceptions
Platform Availability
Available on all platforms except BlackBerry 10, Desktop Web and Windows Kiosk*. *Dummy Implementation on Mobile Web.
This API specifies the callback function that needs to be executed for a registered data stream.
Syntax
kony.stream.setCallback(streamObject,callbackfunction)
Input Parameters
Example
//Callback function for setCallback
myCallbackFunctionRegister: function(status, data, context) { //Execute the logic here alert("You have successfully registered a streaming service"); }
function setCallback() { kony.stream.setCallback(streamObj, myCallbackFunction1); }
Return Values
None
Exceptions
Platform Availability
Available on all platforms except Desktop Web and Windows Kiosk*. *Dummy Implementation on Mobile Web.
Copyright © 2013 Kony, Inc. All rights reserved. |