跳到主要内容

Relay Server

Purpose

This document aims to create the JsonRpc contract between a client and a server.

Definitions

The following definitions are shared concepts across all JSON-RPC methods for the Relay API:

  • topic - a target topic for the message to be subscribed by the receiver.
  • message - a plaintext message to be relayed to any subscribers on the topic.
  • ttl - a storage duration for the message to be cached server-side in seconds (aka time-to-live).
  • tag - a label that identifies what type of message is sent based on the rpc method used.
  • prompt - a flag that identifies whether the server should trigger a notification webhook to a client through a push server.
  • id - a unique identifier for each subscription targetting a topic.

Publish payload

Used when a client publishes a message to a server.

{
"id" : "1",
"jsonrpc": "2.0",
"method": "irn_publish",
"params" : {
"topic" : string,
"message" : string,
"ttl" : seconds,
"tag" : number, // optional / default = 0
"prompt" : boolean, // optional / default = false
}
}

Subcribe payload

Used when a client subscribes a given topic.

{
"id" : "1",
"jsonrpc": "2.0",
"method": "irn_subscribe",
"params" : {
"topic" : string
}
}

Unsubcribe payload

Used when a client unsubscribes a given topic.

{
"id" : "1",
"jsonrpc": "2.0",
"method": "irn_unsubscribe",
"params" : {
"topic" : string,
"id": string
}
}

Subscription payload

Used when a server sends a subscription message to a client.

{
"id" : "1",
"jsonrpc": "2.0",
"method": "irn_subscription",
"params" : {
"id" : string,
"data" : {
"topic" : string,
"message": string
}
}
}

FAQ

  • What is a client? - Any SDK instance (Sign, Chat, Auth, Push)