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:
stop method
Stops cobalt.
Also see: StateEvent
Parameters
| Name | Type | Description |
|---|
| params | null | Always null |
Result
| Name | Type | Description |
|---|
| result | null | Always null |
Errors
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
| Name | Type | Description |
|---|
| params | null | Always null |
Result
| Name | Type | Description |
|---|
| result | null | Always null |
Errors
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
| Name | Type | Description |
|---|
| params | null | Always null |
Result
| Name | Type | Description |
|---|
| result | null | Always null |
Errors
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
| Name | Type | Description |
|---|
| params | null | Always null |
Result
| Name | Type | Description |
|---|
| result | object | State Info |
| result.pid | integer | Pid of cobalt |
| result.state | integer | State of cobalt. 0 - started, 1- stopped, 2 - suspended (background), 99 - unknown |
Errors
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
| Name | Type | Description |
|---|
| params | null | Always null |
Result
| Name | Type | Description |
|---|
| result | object | Url Info |
| result.url | string | Url passed to cobalt. Can be empty string when default is used |
Errors
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
| Name | Type | Description |
|---|
| params | object | Deeplink to set |
| params.data | string | Deeplink to pass to cobalt |
Result
| Name | Type | Description |
|---|
| result | null | Always null |
Errors
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
| Name | Type | Description |
|---|
| params | object | |
| params.event | string | Event type (must be one of the following: StateEvent) |
| params.id | string | Id of the listener |
Result
| Name | Type | Description |
|---|
| result | integer | Value 0 on success |
Errors
| Code | Message | Description |
|---|
| -32602 | INVALID_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
| Name | Type | Description |
|---|
| params | object | |
| params?.event | string | (optional) Event type (must be one of the following: StateEvent) |
| params.id | string | Id of the listener |
Result
| Name | Type | Description |
|---|
| result | integer | Value 0 on success |
Errors
| Code | Message | Description |
|---|
| -32602 | INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised: Wrong parameters | |
| -1 | Registration 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
| Name | Type | Description |
|---|
| result | object | |
| result.listeners | array | |
| result.listeners[#] | object | Listener Info |
| result.listeners[#]?.event | string | (optional) Event type (must be one of the following: StateEvent) |
| result.listeners[#]?.id | string | (optional) Id of the listener |
Errors
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:
| Event | Description |
|---|
| StateEvent | Cobalt state changed event |
StateEvent event
Cobalt state changed event.
Description
Notification of changed state of cobalt
Parameters
| Name | Type | Description |
|---|
| params | object | |
| params.pid | integer | Pid of cobalt |
| params.state | integer | State of cobalt. 0 - started, 1- stopped, 2 - suspended (background), 99 - unknown |
| params.code | integer | Exit code of cobalt |
Example
{
"jsonrpc": "2.0",
"method": "client.events.1.StateEvent",
"params": {
"pid": 1001,
"state": 0,
"code": 0
}
}