-
Notifications
You must be signed in to change notification settings - Fork 447
/
Copy pathsubscribeChannelsRequest.ts
40 lines (35 loc) · 1.11 KB
/
subscribeChannelsRequest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ts-strict-ignore
import { ChannelAddress } from "../../../shared/type/channeladdress";
import { JsonrpcRequest } from "../base";
import { JsonRpcUtils } from "../jsonrpcutils";
/**
* Represents a JSON-RPC Request to subscribe to channels. The actual channel
* data is then sent as JSON-RPC Notification
*
* <pre>
* {
* "jsonrpc": "2.0",
* "id": UUID,
* "method": "subscribeChannels",
* "params": {
* "count": number
* "channels": string[]
* }
* }
* </pre>
*/
export class SubscribeChannelsRequest extends JsonrpcRequest {
// holds the global last count. This is used in Backend to identify the latest Request.
private static lastCount: number = 0;
private static METHOD: string = "subscribeChannels";
public constructor(
private channels: ChannelAddress[],
) {
super(SubscribeChannelsRequest.METHOD, {
count: SubscribeChannelsRequest.lastCount++,
channels: JsonRpcUtils.channelsToStringArray(channels),
});
// delete local fields, otherwise they are sent with the JSON-RPC Request
delete this.channels;
}
}