cobalt-wsrpc API

Version: 0.0.1

Table of Contents

Description

cobalt-wsrpc JSON RPC 2.0 interface.

Methods

The following methods are provided by the org.rdk.cobalt interface:

MethodDescription
stopStops cobalt
suspendSuspends cobalt
resumeResumes cobalt
getStateGets cobalt state
getUrlGets cobalt url
deepLinkSets cobalt deeplink
registerRegisters event listener
unregisterRegisters event listener
getListenersReturns information about registered listeners

stop method

Stops cobalt.

Also see: StateEvent

Parameters

NameTypeDescription
paramsnullAlways null

Result

NameTypeDescription
resultnullAlways null

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.stop",
    "params": null
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": null
}

suspend method

Suspends cobalt.

Also see: StateEvent

Parameters

NameTypeDescription
paramsnullAlways null

Result

NameTypeDescription
resultnullAlways null

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.suspend",
    "params": null
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": null
}

resume method

Resumes cobalt.

Also see: StateEvent

Parameters

NameTypeDescription
paramsnullAlways null

Result

NameTypeDescription
resultnullAlways null

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.resume",
    "params": null
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": null
}

getState method

Gets cobalt state.

Also see: StateEvent

Parameters

NameTypeDescription
paramsnullAlways null

Result

NameTypeDescription
resultobjectState Info
result.pidintegerPid of cobalt
result.stateintegerState of cobalt. 0 - started, 1- stopped, 2 - suspended (background), 99 - unknown

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.getState",
    "params": null
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": {
        "pid": 1001,
        "state": 0
    }
}

getUrl method

Gets cobalt url.

Parameters

NameTypeDescription
paramsnullAlways null

Result

NameTypeDescription
resultobjectUrl Info
result.urlstringUrl passed to cobalt. Can be empty string when default is used

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.getUrl",
    "params": null
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": {
        "url": "https://www.youtube.com/tv"
    }
}

deepLink method

Sets cobalt deeplink.

Parameters

NameTypeDescription
paramsobjectDeeplink to set
params.datastringDeeplink to pass to cobalt

Result

NameTypeDescription
resultnullAlways null

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.deepLink",
    "params": {
        "data": ""
    }
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": null
}

register method

Registers event listener.

Parameters

NameTypeDescription
paramsobject
params.eventstringEvent type (must be one of the following: StateEvent)
params.idstringId of the listener

Result

NameTypeDescription
resultintegerValue 0 on success

Errors

CodeMessageDescription
-32602INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised: Wrong parameters

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.register",
    "params": {
        "event": "StateEvent",
        "id": "events.1"
    }
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": 0
}

unregister method

Registers event listener.

Parameters

NameTypeDescription
paramsobject
params?.eventstring(optional) Event type (must be one of the following: StateEvent)
params.idstringId of the listener

Result

NameTypeDescription
resultintegerValue 0 on success

Errors

CodeMessageDescription
-32602INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised: Wrong parameters
-1Registration info not found

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.unregister",
    "params": {
        "event": "StateEvent",
        "id": "events.1"
    }
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": 0
}

getListeners method

Returns information about registered listeners.

Parameters

This method takes no parameters.

Result

NameTypeDescription
resultobject
result.listenersarray
result.listeners[#]objectListener Info
result.listeners[#]?.eventstring(optional) Event type (must be one of the following: StateEvent)
result.listeners[#]?.idstring(optional) Id of the listener

Errors

CodeMessageDescription

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "org.rdk.cobalt.1.getListeners"
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": {
        "listeners": [
            {
                "event": "StateEvent",
                "id": "events.1"
            }
        ]
    }
}

Notifications

Notifications are autonomous events, triggered by the internals of the implementation, and broadcasted via JSON-RPC to all registered observers.

The following events are provided by the org.rdk.cobalt interface:

EventDescription
StateEventCobalt state changed event

StateEvent event

Cobalt state changed event.

Description

Notification of changed state of cobalt

Parameters

NameTypeDescription
paramsobject
params.pidintegerPid of cobalt
params.stateintegerState of cobalt. 0 - started, 1- stopped, 2 - suspended (background), 99 - unknown
params.codeintegerExit code of cobalt

Example

{
    "jsonrpc": "2.0",
    "method": "client.events.1.StateEvent",
    "params": {
        "pid": 1001,
        "state": 0,
        "code": 0
    }
}