Skip to content

StateControl API

Version: 1.0.0

Status: ⚫⚪⚪

StateControl interface for Thunder framework.

(Defined by StateControl.json)

Table of Contents

Introduction

Scope

This document describes purpose and functionality of the StateControl interface (version 1.0.0). It includes detailed specification about its properties provided and notifications sent.

Case Sensitivity

All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.

Acronyms, Abbreviations and Terms

The table below provides and overview of acronyms used in this document and their definitions.

Acronym Description
API Application Programming Interface
HTTP Hypertext Transfer Protocol
JSON JavaScript Object Notation; a data interchange format
JSON-RPC A remote procedure call protocol encoded in JSON

The table below provides and overview of terms and abbreviations used in this document and their definitions.

Term Description
callsign The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique.

References

Ref ID Description
HTTP HTTP specification
JSON-RPC JSON-RPC 2.0 specification
JSON JSON specification
Thunder Thunder API Reference

Description

StateControl JSON-RPC interface.

Properties

The following properties are provided by the StateControl interface:

StateControl interface properties:

Property R/W Description
state read/write Running state of the service

state property

Provides access to the running state of the service.

Also see: statechange

Value

Name Type M/O Description
(property) string mandatory Running state of the service (must be one of the following: resumed, suspended)
Name Type M/O Description
(property) string mandatory Running state of the service (must be one of the following: resumed, suspended)

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "<callsign>.1.state"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "suspended"
}

Set Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "<callsign>.1.state",
  "params": "suspended"
}

Set Response

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

Notifications

Notifications are autonomous events triggered by the internals of the implementation and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.

The following events are provided by the StateControl interface:

StateControl interface events:

Notification Description
statechange Signals a state change of the service

statechange notification

Signals a state change of the service.

Notification Parameters

Name Type M/O Description
params object mandatory ...
params.suspended boolean mandatory Determines if the service has entered suspended state (true) or resumed state (false)

Example

Registration

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "<callsign>.1.register",
  "params": {
    "event": "statechange",
    "id": "myid"
  }
}

Notification

{
  "jsonrpc": "2.0",
  "method": "myid.statechange",
  "params": {
    "suspended": false
  }
}

The client ID parameter is passed within the notification designator, i.e. <client-id>.statechange.