You are here: Streaming API > deregisterDataStream

kony.stream Namespace

The kony.stream namespace forms the Streaming API and provides the following API elements.

Functions

The kony.stream namespace provides the following functions.

kony.stream.deregisterDataStream

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.


kony.stream.registerDataStream

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

ParameterDescription
protocol [String] - Mandatory

Specifies the underlying streaming protocol to be used. Kony currently supports only HTTP1.1 protocol.

configparams [Table] - Mandatory

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:

  • url [String] - Mandatory: Specifies the URL of the streaming server of a web site that has data that can be streamed. For example: url="http://www.mobilestreaming.kony.com.
  • cookie [Object] - Optional:Specifies an Object with the following key-value pairs:
    • streamingid (String)
    • jessessionid (String)
    cookie = {
        streamingid: "12218181agdgdhjhjd",
        jessessionid: "198181819919agagah1t1g1"
    };
  • headers [Object] - Optional: Specifies the header parameters.
    //For example: {authmode:basic}
  • params [Object] - Optional: Specifies any additional parameters.

For example: {quote:"goog"}

  • method [String] - Mandatory: Specifies the method. Possible values are:
  • get
  • post(Default value is post)

For example: "post"

outputformat [String] - Mandatory.

Specifies the output format of the stream. Currently supported values are:

  • String (default)
  • JSON

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.

callback [Function] - Mandatory.

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)

  • status[Number] - indicates the status of the streaming operation. Possible values are:
    • 0 - indicates success
    • 1011 - Device has no wifi or mobile connectivity. Please try the operation after establishing connectivity.
    • 1012 - Request Failed .This is a generic error and is thrown if the platform is not able to differentiate between various errors.
    • 1014 - Request timed out
    • 1015 - Cannot find host.
    • 1016 - Cannot connect to host.
    • 1002 - Error reading from stream.
    • 1019 - Error writing into stream.
    • 1020 - End of stream with errors.
    • 1021 - End of stream.
  • data[Object or String] - If the output format is JSON it is an Object and if the output format is string, it is a String. Incase of any error, data will be null/nil.
  • context[Object] - Contains additional information that needs to be passed to the underlying streaming API. For HTTP1.1 protocol, this table contains a value httpresponsecode.

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

Exceptions

Platform Availability

Available on all platforms except BlackBerry 10, Desktop Web and Windows Kiosk*. *Dummy Implementation on Mobile Web.


kony.stream.setCallback

This API specifies the callback function that needs to be executed for a registered data stream.

Syntax

kony.stream.setCallback(streamObject,callbackfunction)

Input Parameters

FunctionDescription
streamObject [String] - MandatorySpecifies the streamObject that identifies the stream.
callbackfunction [Function] - MandatorySpecifies the callback function that needs to be executed.
 

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.