forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
148 lines (104 loc) · 5.84 KB
/
index.d.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Type definitions for ag-simple-broker 4.0
// Project: https://github.com/SocketCluster/ag-simple-broker
// Definitions by: Daniel Rose <https://github.com/DanielRose>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import AsyncStreamEmitter = require('async-stream-emitter');
import AGServer = require('socketcluster-server/server');
import ConsumableStream = require('consumable-stream');
import AGChannel = require('ag-channel');
import Consumer = require('writable-consumable-stream/consumer');
declare class AGSimpleBroker extends AsyncStreamEmitter<any> {
isReady: boolean;
emit(eventName: 'ready', data: {}): void;
emit(eventName: 'subscribe', data: AGSimpleBroker.SubscribeData): void;
emit(eventName: 'unsubscribe', data: AGSimpleBroker.UnsubscribeData): void;
emit(eventName: 'error', data: { error: Error }): void;
emit(eventName: 'publish', data: AGSimpleBroker.PublishData): void;
listener(eventName: 'ready'): ConsumableStream<{}>;
listener(eventName: 'subscribe'): ConsumableStream<AGSimpleBroker.SubscribeData>;
listener(eventName: 'unsubscribe'): ConsumableStream<AGSimpleBroker.UnsubscribeData>;
listener(eventName: 'error'): ConsumableStream<{ error: Error }>;
listener(eventName: 'publish'): ConsumableStream<AGSimpleBroker.PublishData>;
exchange(): AGSimpleBroker.SimpleExchange;
subscribeClient(client: { id: string }, channelName: string): Promise<void>;
subscribeSocket(client: { id: string }, channelName: string): Promise<void>;
unsubscribeClient(client: { id: string }, channelName: string): Promise<void>;
unsubscribeSocket(client: { id: string }, channelName: string): Promise<void>;
subscriptions(): string[];
isSubscribed(channelName: string): boolean;
setCodecEngine(codec: AGServer.CodecEngine): void;
invokePublish(channelName: string, data: any, suppressEvent?: boolean): Promise<void>;
transmitPublish(channelName: string, data: any, suppressEvent?: boolean): Promise<void>;
}
export = AGSimpleBroker;
declare namespace AGSimpleBroker {
class SimpleExchange extends AsyncStreamEmitter<any> implements AGChannel.Client {
id: string;
constructor(broker: AGSimpleBroker);
emit(eventName: 'subscribe', data: SubscribeData): void;
emit(eventName: 'unsubscribe', data: UnsubscribeData): void;
listener(eventName: 'subscribe'): ConsumableStream<SubscribeData>;
listener(eventName: 'unsubscribe'): ConsumableStream<UnsubscribeData>;
/* AGChannel.Client start */
closeChannel(channelName: string): void;
killChannel(channelName: string): void;
killChannelOutputConsumer(consumerId: number): void;
killChannelListenerConsumer(consumerId: number): void;
getChannelOutputConsumerStats(consumerId: number): Consumer.ConsumerStats;
getChannelListenerConsumerStats(consumerId: number): Consumer.ConsumerStats;
getChannelBackpressure(channelName: string): number;
getChannelListenerConsumerBackpressure(consumerId: number): number;
getChannelOutputConsumerBackpressure(consumerId: number): number;
channelCloseOutput(channelName: string): void;
channelCloseListener(channelName: string, eventName: string): void;
channelCloseAllListeners(channelName: string): void;
channelKillOutput(channelName: string): void;
channelKillListener(channelName: string, eventName: string): void;
channelKillAllListeners(channelName: string): void;
channelGetOutputConsumerStatsList(channelName: string): Consumer.ConsumerStats[];
channelGetListenerConsumerStatsList(channelName: string, eventName: string): Consumer.ConsumerStats[];
channelGetAllListenersConsumerStatsList(channelName: string): Consumer.ConsumerStats[];
channelGetOutputBackpressure(channelName: string): number;
channelGetListenerBackpressure(channelName: string, eventName: string): number;
channelGetAllListenersBackpressure(channelName: string): number;
channelHasOutputConsumer(channelName: string, consumerId: number): boolean;
channelHasListenerConsumer(channelName: string, eventName: string, consumerId: number): boolean;
channelHasAnyListenerConsumer(channelName: string, consumerId: number): boolean;
getChannelState(channelName: string): AGChannel.ChannelState;
getChannelOptions(channelName: string): object;
subscribe(channelName: string): AGChannel<any>;
unsubscribe(channelName: string): Promise<void>;
isSubscribed(channelName: string, includePending?: boolean): boolean;
transmitPublish(channelName: string, data: any): Promise<void>;
invokePublish(channelName: string, data: any): Promise<void>;
/* AGChannel.Client end */
transmit(event: string, packet: any): void;
destroy(): void;
channel(channelName: string): AGChannel<any>;
closeAllChannelOutputs(): void;
closeAllChannelListeners(): void;
closeAllChannels(): void;
killAllChannelOutputs(): void;
killAllChannelListeners(): void;
killAllChannels(): void;
getAllChannelOutputsConsumerStatsList(): Consumer.ConsumerStats[];
getAllChannelListenersConsumerStatsList(): Consumer.ConsumerStats[];
getBackpressure(): number;
getAllChannelOutputsBackpressure(): number;
getAllChannelListenersBackpressure(): number;
getAllChannelsBackpressure(): number;
hasAnyChannelOutputConsumer(consumerId: number): boolean;
hasAnyChannelListenerConsumer(consumerId: number): boolean;
subscriptions(includePending?: boolean): string[];
}
interface SubscribeData {
channel: string;
}
interface UnsubscribeData {
channel: string;
}
interface PublishData {
channel: string;
date: any;
}
}