centrifuge 4.0.1 → 5.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/build/centrifuge.d.ts +158 -169
- package/build/cjs/centrifuge.d.ts +158 -0
- package/build/cjs/codes.d.ts +36 -0
- package/build/cjs/protobuf.d.ts +8 -0
- package/build/cjs/protobuf.js +11753 -0
- package/build/cjs/subscription.d.ts +83 -0
- package/build/cjs/types.d.ts +287 -0
- package/build/codes.d.ts +36 -36
- package/build/esm/centrifuge.d.ts +158 -0
- package/build/esm/codes.d.ts +36 -0
- package/build/esm/index.d.ts +5 -0
- package/build/{json.d.ts → esm/json.d.ts} +1 -1
- package/build/esm/protobuf.codec.d.ts +1 -0
- package/build/esm/protobuf.d.ts +8 -0
- package/build/esm/protobuf.js +11749 -0
- package/build/esm/subscription.d.ts +83 -0
- package/build/{transport_http_stream.d.ts → esm/transport_http_stream.d.ts} +1 -1
- package/build/{transport_sockjs.d.ts → esm/transport_sockjs.d.ts} +1 -1
- package/build/{transport_sse.d.ts → esm/transport_sse.d.ts} +1 -1
- package/build/{transport_websocket.d.ts → esm/transport_websocket.d.ts} +1 -1
- package/build/{transport_webtransport.d.ts → esm/transport_webtransport.d.ts} +1 -1
- package/build/esm/types.d.ts +287 -0
- package/build/{utils.d.ts → esm/utils.d.ts} +1 -1
- package/build/index.d.ts +5 -4
- package/build/index.js +3422 -23
- package/build/index.mjs +3418 -0
- package/build/subscription.d.ts +83 -83
- package/build/types.d.ts +287 -290
- package/dist/centrifuge.js +6 -6
- package/dist/centrifuge.js.map +4 -4
- package/dist/centrifuge.protobuf.js +7 -7
- package/dist/centrifuge.protobuf.js.map +4 -4
- package/package.json +12 -5
- package/build/centrifuge.js +0 -1680
- package/build/centrifuge.js.map +0 -1
- package/build/codes.js +0 -40
- package/build/codes.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/json.js +0 -18
- package/build/json.js.map +0 -1
- package/build/protobuf/client.proto.json +0 -836
- package/build/protobuf/index.d.ts +0 -18
- package/build/protobuf/index.js +0 -64
- package/build/protobuf/index.js.map +0 -1
- package/build/subscription.js +0 -620
- package/build/subscription.js.map +0 -1
- package/build/transport_http_stream.js +0 -201
- package/build/transport_http_stream.js.map +0 -1
- package/build/transport_sockjs.js +0 -46
- package/build/transport_sockjs.js.map +0 -1
- package/build/transport_sse.js +0 -89
- package/build/transport_sse.js.map +0 -1
- package/build/transport_websocket.js +0 -58
- package/build/transport_websocket.js.map +0 -1
- package/build/transport_webtransport.js +0 -177
- package/build/transport_webtransport.js.map +0 -1
- package/build/types.js +0 -18
- package/build/types.js.map +0 -1
- package/build/utils.js +0 -52
- package/build/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -305,6 +305,10 @@ centrifuge.presenceStats("channel").then(function(resp) {
|
|
|
305
305
|
|
|
306
306
|
Returns a Promise which will be resolved upon connection establishement (i.e. when Client goes to `connected` state).
|
|
307
307
|
|
|
308
|
+
#### setToken method
|
|
309
|
+
|
|
310
|
+
`setToken` may be useful to dynamically change the connection token. For example when you need to implement login/logout workflow. See an example in [blog post](https://centrifugal.dev/blog/2023/06/29/centrifugo-v5-released#token-behaviour-adjustments-in-sdks).
|
|
311
|
+
|
|
308
312
|
#### error event
|
|
309
313
|
|
|
310
314
|
To listen asynchronous error happening internally while Centrifuge client works you can set an `error` handler:
|
|
@@ -333,7 +337,7 @@ In case of Centrifugo on a server side this may be a JSON Web Token - see [authe
|
|
|
333
337
|
|
|
334
338
|
**Connection token must come to the frontend from application backend - i.e. must be generated on the backend side**. The way to deliver token to the application frontend is up to the developer. Usually you can pass it in template rendering context or issue a separate call to request a connection token from the backend.
|
|
335
339
|
|
|
336
|
-
If the token sets connection expiration then the client SDK will keep the token refreshed. It does this by calling a special callback function. This callback must return a new token. If a new token with updated connection expiration is returned from callback then it's sent to Centrifugo.
|
|
340
|
+
If the token sets connection expiration then the client SDK will keep the token refreshed. It does this by calling a special callback function. This callback must return a new token. If a new token with updated connection expiration is returned from callback then it's sent to Centrifugo. In case of error returned by your callback SDK will retry the operation after some jittered time. You can throw a special error (`throw new Centrifuge.UnauthorizedError();`) from `getToken` function to move the client into disconnected state (for example, when there is no permission to connect anymore).
|
|
337
341
|
|
|
338
342
|
An example of possible `getToken` function implementation:
|
|
339
343
|
|
package/build/centrifuge.d.ts
CHANGED
|
@@ -1,169 +1,158 @@
|
|
|
1
|
-
import { Subscription } from './subscription';
|
|
2
|
-
import { State, Options, ClientEvents, TypedEventEmitter, RpcResult, SubscriptionOptions, HistoryOptions, HistoryResult, PublishResult, PresenceResult, PresenceStatsResult, TransportEndpoint } from './types';
|
|
3
|
-
export declare class UnauthorizedError extends Error {
|
|
4
|
-
constructor(message: any);
|
|
5
|
-
}
|
|
6
|
-
declare const Centrifuge_base: new () => TypedEventEmitter<ClientEvents>;
|
|
7
|
-
/** Centrifuge is a Centrifuge/Centrifugo bidirectional client. */
|
|
8
|
-
export declare class Centrifuge extends Centrifuge_base {
|
|
9
|
-
state: State;
|
|
10
|
-
private _endpoint;
|
|
11
|
-
private _emulation;
|
|
12
|
-
private _transports;
|
|
13
|
-
private _currentTransportIndex;
|
|
14
|
-
private _triedAllTransports;
|
|
15
|
-
private _transportWasOpen;
|
|
16
|
-
private _transport?;
|
|
17
|
-
private _transportId;
|
|
18
|
-
private _deviceWentOffline;
|
|
19
|
-
private _transportClosed;
|
|
20
|
-
private _reconnecting;
|
|
21
|
-
private _reconnectTimeout?;
|
|
22
|
-
private _reconnectAttempts;
|
|
23
|
-
private _client;
|
|
24
|
-
private _session;
|
|
25
|
-
private _node;
|
|
26
|
-
private _subs;
|
|
27
|
-
private _serverSubs;
|
|
28
|
-
private _commandId;
|
|
29
|
-
private _commands;
|
|
30
|
-
private _batching;
|
|
31
|
-
private _refreshRequired;
|
|
32
|
-
private _refreshTimeout?;
|
|
33
|
-
private _callbacks;
|
|
34
|
-
private _token;
|
|
35
|
-
private _data;
|
|
36
|
-
private _dispatchPromise;
|
|
37
|
-
private _serverPing;
|
|
38
|
-
private _serverPingTimeout?;
|
|
39
|
-
private _sendPong;
|
|
40
|
-
private _promises;
|
|
41
|
-
private _promiseId;
|
|
42
|
-
private _networkEventsSet;
|
|
43
|
-
private _debugEnabled;
|
|
44
|
-
private _config;
|
|
45
|
-
protected
|
|
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
|
-
private
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private
|
|
107
|
-
private
|
|
108
|
-
private
|
|
109
|
-
private
|
|
110
|
-
private
|
|
111
|
-
private
|
|
112
|
-
private
|
|
113
|
-
private
|
|
114
|
-
private
|
|
115
|
-
private
|
|
116
|
-
private
|
|
117
|
-
private
|
|
118
|
-
private
|
|
119
|
-
private
|
|
120
|
-
private
|
|
121
|
-
private
|
|
122
|
-
private
|
|
123
|
-
private
|
|
124
|
-
private
|
|
125
|
-
private
|
|
126
|
-
|
|
127
|
-
private
|
|
128
|
-
private
|
|
129
|
-
private
|
|
130
|
-
private
|
|
131
|
-
private
|
|
132
|
-
private
|
|
133
|
-
private
|
|
134
|
-
private
|
|
135
|
-
private
|
|
136
|
-
private
|
|
137
|
-
|
|
138
|
-
private
|
|
139
|
-
private
|
|
140
|
-
private
|
|
141
|
-
private
|
|
142
|
-
private
|
|
143
|
-
private
|
|
144
|
-
private
|
|
145
|
-
private
|
|
146
|
-
private
|
|
147
|
-
private
|
|
148
|
-
private
|
|
149
|
-
private
|
|
150
|
-
private
|
|
151
|
-
private
|
|
152
|
-
private
|
|
153
|
-
private
|
|
154
|
-
private
|
|
155
|
-
private
|
|
156
|
-
private
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
private _handlePush;
|
|
160
|
-
private _flush;
|
|
161
|
-
private _createErrorObject;
|
|
162
|
-
private _registerCall;
|
|
163
|
-
private _addCommand;
|
|
164
|
-
private _nextPromiseId;
|
|
165
|
-
private _nextTransportId;
|
|
166
|
-
private _resolvePromises;
|
|
167
|
-
private _rejectPromises;
|
|
168
|
-
}
|
|
169
|
-
export {};
|
|
1
|
+
import { Subscription } from './subscription';
|
|
2
|
+
import { State, Options, ClientEvents, TypedEventEmitter, RpcResult, SubscriptionOptions, HistoryOptions, HistoryResult, PublishResult, PresenceResult, PresenceStatsResult, TransportEndpoint } from './types';
|
|
3
|
+
export declare class UnauthorizedError extends Error {
|
|
4
|
+
constructor(message: any);
|
|
5
|
+
}
|
|
6
|
+
declare const Centrifuge_base: new () => TypedEventEmitter<ClientEvents>;
|
|
7
|
+
/** Centrifuge is a Centrifuge/Centrifugo bidirectional client. */
|
|
8
|
+
export declare class Centrifuge extends Centrifuge_base {
|
|
9
|
+
state: State;
|
|
10
|
+
private _endpoint;
|
|
11
|
+
private _emulation;
|
|
12
|
+
private _transports;
|
|
13
|
+
private _currentTransportIndex;
|
|
14
|
+
private _triedAllTransports;
|
|
15
|
+
private _transportWasOpen;
|
|
16
|
+
private _transport?;
|
|
17
|
+
private _transportId;
|
|
18
|
+
private _deviceWentOffline;
|
|
19
|
+
private _transportClosed;
|
|
20
|
+
private _reconnecting;
|
|
21
|
+
private _reconnectTimeout?;
|
|
22
|
+
private _reconnectAttempts;
|
|
23
|
+
private _client;
|
|
24
|
+
private _session;
|
|
25
|
+
private _node;
|
|
26
|
+
private _subs;
|
|
27
|
+
private _serverSubs;
|
|
28
|
+
private _commandId;
|
|
29
|
+
private _commands;
|
|
30
|
+
private _batching;
|
|
31
|
+
private _refreshRequired;
|
|
32
|
+
private _refreshTimeout?;
|
|
33
|
+
private _callbacks;
|
|
34
|
+
private _token;
|
|
35
|
+
private _data;
|
|
36
|
+
private _dispatchPromise;
|
|
37
|
+
private _serverPing;
|
|
38
|
+
private _serverPingTimeout?;
|
|
39
|
+
private _sendPong;
|
|
40
|
+
private _promises;
|
|
41
|
+
private _promiseId;
|
|
42
|
+
private _networkEventsSet;
|
|
43
|
+
private _debugEnabled;
|
|
44
|
+
private _config;
|
|
45
|
+
protected _codec: any;
|
|
46
|
+
/** Constructs Centrifuge client. Call connect() method to start connecting. */
|
|
47
|
+
constructor(endpoint: string | Array<TransportEndpoint>, options?: Partial<Options>);
|
|
48
|
+
/** newSubscription allocates new Subscription to a channel. Since server only allows
|
|
49
|
+
* one subscription per channel per client this method throws if client already has
|
|
50
|
+
* channel subscription in internal registry.
|
|
51
|
+
* */
|
|
52
|
+
newSubscription(channel: string, options?: Partial<SubscriptionOptions>): Subscription;
|
|
53
|
+
/** getSubscription returns Subscription if it's registered in the internal
|
|
54
|
+
* registry or null. */
|
|
55
|
+
getSubscription(channel: string): Subscription | null;
|
|
56
|
+
/** removeSubscription allows removing Subcription from the internal registry. Subscrption
|
|
57
|
+
* must be in unsubscribed state. */
|
|
58
|
+
removeSubscription(sub: Subscription | null): void;
|
|
59
|
+
/** Get a map with all current client-side subscriptions. */
|
|
60
|
+
subscriptions(): Record<string, Subscription>;
|
|
61
|
+
/** ready returns a Promise which resolves upon client goes to Connected
|
|
62
|
+
* state and rejects in case of client goes to Disconnected or Failed state.
|
|
63
|
+
* Users can provide optional timeout in milliseconds. */
|
|
64
|
+
ready(timeout?: number): Promise<void>;
|
|
65
|
+
/** connect to a server. */
|
|
66
|
+
connect(): void;
|
|
67
|
+
/** disconnect from a server. */
|
|
68
|
+
disconnect(): void;
|
|
69
|
+
/** setToken allows setting connection token. Or resetting used token to be empty. */
|
|
70
|
+
setToken(token: string): void;
|
|
71
|
+
/** send asynchronous data to a server (without any response from a server
|
|
72
|
+
* expected, see rpc method if you need response). */
|
|
73
|
+
send(data: any): Promise<void>;
|
|
74
|
+
/** rpc to a server - i.e. a call which waits for a response with data. */
|
|
75
|
+
rpc(method: string, data: any): Promise<RpcResult>;
|
|
76
|
+
/** publish data to a channel. */
|
|
77
|
+
publish(channel: string, data: any): Promise<PublishResult>;
|
|
78
|
+
/** history for a channel. By default it does not return publications (only current
|
|
79
|
+
* StreamPosition data) – provide an explicit limit > 0 to load publications.*/
|
|
80
|
+
history(channel: string, options?: HistoryOptions): Promise<HistoryResult>;
|
|
81
|
+
/** presence for a channel. */
|
|
82
|
+
presence(channel: string): Promise<PresenceResult>;
|
|
83
|
+
/** presence stats for a channel. */
|
|
84
|
+
presenceStats(channel: string): Promise<PresenceStatsResult>;
|
|
85
|
+
/** start command batching (collect into temporary buffer without sending to a server)
|
|
86
|
+
* until stopBatching called.*/
|
|
87
|
+
startBatching(): void;
|
|
88
|
+
/** stop batching commands and flush collected commands to the
|
|
89
|
+
* network (all in one request/frame).*/
|
|
90
|
+
stopBatching(): void;
|
|
91
|
+
private _debug;
|
|
92
|
+
private _configure;
|
|
93
|
+
private _setState;
|
|
94
|
+
private _isDisconnected;
|
|
95
|
+
private _isConnecting;
|
|
96
|
+
private _isConnected;
|
|
97
|
+
private _nextCommandId;
|
|
98
|
+
private _setNetworkEvents;
|
|
99
|
+
private _getReconnectDelay;
|
|
100
|
+
private _clearOutgoingRequests;
|
|
101
|
+
private _clearConnectedState;
|
|
102
|
+
private _handleWriteError;
|
|
103
|
+
private _transportSendCommands;
|
|
104
|
+
private _initializeTransport;
|
|
105
|
+
private _sendConnect;
|
|
106
|
+
private _startReconnecting;
|
|
107
|
+
private _connectError;
|
|
108
|
+
private _scheduleReconnect;
|
|
109
|
+
private _constructConnectCommand;
|
|
110
|
+
private _getHistoryRequest;
|
|
111
|
+
private _methodCall;
|
|
112
|
+
private _callPromise;
|
|
113
|
+
private _dataReceived;
|
|
114
|
+
private _dispatchSynchronized;
|
|
115
|
+
private _dispatchReply;
|
|
116
|
+
private _call;
|
|
117
|
+
private _startConnecting;
|
|
118
|
+
private _disconnect;
|
|
119
|
+
private _failUnauthorized;
|
|
120
|
+
private _getToken;
|
|
121
|
+
private _refresh;
|
|
122
|
+
private _refreshError;
|
|
123
|
+
private _getRefreshRetryDelay;
|
|
124
|
+
private _refreshResponse;
|
|
125
|
+
private _removeSubscription;
|
|
126
|
+
protected _unsubscribe(sub: Subscription): void;
|
|
127
|
+
private _getSub;
|
|
128
|
+
private _isServerSub;
|
|
129
|
+
private _sendSubscribeCommands;
|
|
130
|
+
private _connectResponse;
|
|
131
|
+
private _processServerSubs;
|
|
132
|
+
private _clearRefreshTimeout;
|
|
133
|
+
private _clearReconnectTimeout;
|
|
134
|
+
private _clearServerPingTimeout;
|
|
135
|
+
private _waitServerPing;
|
|
136
|
+
private _getSubscribeContext;
|
|
137
|
+
private _handleReply;
|
|
138
|
+
private _handleJoin;
|
|
139
|
+
private _handleLeave;
|
|
140
|
+
private _handleUnsubscribe;
|
|
141
|
+
private _handleSubscribe;
|
|
142
|
+
private _handleDisconnect;
|
|
143
|
+
private _getPublicationContext;
|
|
144
|
+
private _getJoinLeaveContext;
|
|
145
|
+
private _handlePublication;
|
|
146
|
+
private _handleMessage;
|
|
147
|
+
private _handleServerPing;
|
|
148
|
+
private _handlePush;
|
|
149
|
+
private _flush;
|
|
150
|
+
private _createErrorObject;
|
|
151
|
+
private _registerCall;
|
|
152
|
+
private _addCommand;
|
|
153
|
+
private _nextPromiseId;
|
|
154
|
+
private _nextTransportId;
|
|
155
|
+
private _resolvePromises;
|
|
156
|
+
private _rejectPromises;
|
|
157
|
+
}
|
|
158
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Subscription } from './subscription';
|
|
2
|
+
import { State, Options, ClientEvents, TypedEventEmitter, RpcResult, SubscriptionOptions, HistoryOptions, HistoryResult, PublishResult, PresenceResult, PresenceStatsResult, TransportEndpoint } from './types';
|
|
3
|
+
export declare class UnauthorizedError extends Error {
|
|
4
|
+
constructor(message: any);
|
|
5
|
+
}
|
|
6
|
+
declare const Centrifuge_base: new () => TypedEventEmitter<ClientEvents>;
|
|
7
|
+
/** Centrifuge is a Centrifuge/Centrifugo bidirectional client. */
|
|
8
|
+
export declare class Centrifuge extends Centrifuge_base {
|
|
9
|
+
state: State;
|
|
10
|
+
private _endpoint;
|
|
11
|
+
private _emulation;
|
|
12
|
+
private _transports;
|
|
13
|
+
private _currentTransportIndex;
|
|
14
|
+
private _triedAllTransports;
|
|
15
|
+
private _transportWasOpen;
|
|
16
|
+
private _transport?;
|
|
17
|
+
private _transportId;
|
|
18
|
+
private _deviceWentOffline;
|
|
19
|
+
private _transportClosed;
|
|
20
|
+
private _reconnecting;
|
|
21
|
+
private _reconnectTimeout?;
|
|
22
|
+
private _reconnectAttempts;
|
|
23
|
+
private _client;
|
|
24
|
+
private _session;
|
|
25
|
+
private _node;
|
|
26
|
+
private _subs;
|
|
27
|
+
private _serverSubs;
|
|
28
|
+
private _commandId;
|
|
29
|
+
private _commands;
|
|
30
|
+
private _batching;
|
|
31
|
+
private _refreshRequired;
|
|
32
|
+
private _refreshTimeout?;
|
|
33
|
+
private _callbacks;
|
|
34
|
+
private _token;
|
|
35
|
+
private _data;
|
|
36
|
+
private _dispatchPromise;
|
|
37
|
+
private _serverPing;
|
|
38
|
+
private _serverPingTimeout?;
|
|
39
|
+
private _sendPong;
|
|
40
|
+
private _promises;
|
|
41
|
+
private _promiseId;
|
|
42
|
+
private _networkEventsSet;
|
|
43
|
+
private _debugEnabled;
|
|
44
|
+
private _config;
|
|
45
|
+
protected _codec: any;
|
|
46
|
+
/** Constructs Centrifuge client. Call connect() method to start connecting. */
|
|
47
|
+
constructor(endpoint: string | Array<TransportEndpoint>, options?: Partial<Options>);
|
|
48
|
+
/** newSubscription allocates new Subscription to a channel. Since server only allows
|
|
49
|
+
* one subscription per channel per client this method throws if client already has
|
|
50
|
+
* channel subscription in internal registry.
|
|
51
|
+
* */
|
|
52
|
+
newSubscription(channel: string, options?: Partial<SubscriptionOptions>): Subscription;
|
|
53
|
+
/** getSubscription returns Subscription if it's registered in the internal
|
|
54
|
+
* registry or null. */
|
|
55
|
+
getSubscription(channel: string): Subscription | null;
|
|
56
|
+
/** removeSubscription allows removing Subcription from the internal registry. Subscrption
|
|
57
|
+
* must be in unsubscribed state. */
|
|
58
|
+
removeSubscription(sub: Subscription | null): void;
|
|
59
|
+
/** Get a map with all current client-side subscriptions. */
|
|
60
|
+
subscriptions(): Record<string, Subscription>;
|
|
61
|
+
/** ready returns a Promise which resolves upon client goes to Connected
|
|
62
|
+
* state and rejects in case of client goes to Disconnected or Failed state.
|
|
63
|
+
* Users can provide optional timeout in milliseconds. */
|
|
64
|
+
ready(timeout?: number): Promise<void>;
|
|
65
|
+
/** connect to a server. */
|
|
66
|
+
connect(): void;
|
|
67
|
+
/** disconnect from a server. */
|
|
68
|
+
disconnect(): void;
|
|
69
|
+
/** setToken allows setting connection token. Or resetting used token to be empty. */
|
|
70
|
+
setToken(token: string): void;
|
|
71
|
+
/** send asynchronous data to a server (without any response from a server
|
|
72
|
+
* expected, see rpc method if you need response). */
|
|
73
|
+
send(data: any): Promise<void>;
|
|
74
|
+
/** rpc to a server - i.e. a call which waits for a response with data. */
|
|
75
|
+
rpc(method: string, data: any): Promise<RpcResult>;
|
|
76
|
+
/** publish data to a channel. */
|
|
77
|
+
publish(channel: string, data: any): Promise<PublishResult>;
|
|
78
|
+
/** history for a channel. By default it does not return publications (only current
|
|
79
|
+
* StreamPosition data) – provide an explicit limit > 0 to load publications.*/
|
|
80
|
+
history(channel: string, options?: HistoryOptions): Promise<HistoryResult>;
|
|
81
|
+
/** presence for a channel. */
|
|
82
|
+
presence(channel: string): Promise<PresenceResult>;
|
|
83
|
+
/** presence stats for a channel. */
|
|
84
|
+
presenceStats(channel: string): Promise<PresenceStatsResult>;
|
|
85
|
+
/** start command batching (collect into temporary buffer without sending to a server)
|
|
86
|
+
* until stopBatching called.*/
|
|
87
|
+
startBatching(): void;
|
|
88
|
+
/** stop batching commands and flush collected commands to the
|
|
89
|
+
* network (all in one request/frame).*/
|
|
90
|
+
stopBatching(): void;
|
|
91
|
+
private _debug;
|
|
92
|
+
private _configure;
|
|
93
|
+
private _setState;
|
|
94
|
+
private _isDisconnected;
|
|
95
|
+
private _isConnecting;
|
|
96
|
+
private _isConnected;
|
|
97
|
+
private _nextCommandId;
|
|
98
|
+
private _setNetworkEvents;
|
|
99
|
+
private _getReconnectDelay;
|
|
100
|
+
private _clearOutgoingRequests;
|
|
101
|
+
private _clearConnectedState;
|
|
102
|
+
private _handleWriteError;
|
|
103
|
+
private _transportSendCommands;
|
|
104
|
+
private _initializeTransport;
|
|
105
|
+
private _sendConnect;
|
|
106
|
+
private _startReconnecting;
|
|
107
|
+
private _connectError;
|
|
108
|
+
private _scheduleReconnect;
|
|
109
|
+
private _constructConnectCommand;
|
|
110
|
+
private _getHistoryRequest;
|
|
111
|
+
private _methodCall;
|
|
112
|
+
private _callPromise;
|
|
113
|
+
private _dataReceived;
|
|
114
|
+
private _dispatchSynchronized;
|
|
115
|
+
private _dispatchReply;
|
|
116
|
+
private _call;
|
|
117
|
+
private _startConnecting;
|
|
118
|
+
private _disconnect;
|
|
119
|
+
private _failUnauthorized;
|
|
120
|
+
private _getToken;
|
|
121
|
+
private _refresh;
|
|
122
|
+
private _refreshError;
|
|
123
|
+
private _getRefreshRetryDelay;
|
|
124
|
+
private _refreshResponse;
|
|
125
|
+
private _removeSubscription;
|
|
126
|
+
protected _unsubscribe(sub: Subscription): void;
|
|
127
|
+
private _getSub;
|
|
128
|
+
private _isServerSub;
|
|
129
|
+
private _sendSubscribeCommands;
|
|
130
|
+
private _connectResponse;
|
|
131
|
+
private _processServerSubs;
|
|
132
|
+
private _clearRefreshTimeout;
|
|
133
|
+
private _clearReconnectTimeout;
|
|
134
|
+
private _clearServerPingTimeout;
|
|
135
|
+
private _waitServerPing;
|
|
136
|
+
private _getSubscribeContext;
|
|
137
|
+
private _handleReply;
|
|
138
|
+
private _handleJoin;
|
|
139
|
+
private _handleLeave;
|
|
140
|
+
private _handleUnsubscribe;
|
|
141
|
+
private _handleSubscribe;
|
|
142
|
+
private _handleDisconnect;
|
|
143
|
+
private _getPublicationContext;
|
|
144
|
+
private _getJoinLeaveContext;
|
|
145
|
+
private _handlePublication;
|
|
146
|
+
private _handleMessage;
|
|
147
|
+
private _handleServerPing;
|
|
148
|
+
private _handlePush;
|
|
149
|
+
private _flush;
|
|
150
|
+
private _createErrorObject;
|
|
151
|
+
private _registerCall;
|
|
152
|
+
private _addCommand;
|
|
153
|
+
private _nextPromiseId;
|
|
154
|
+
private _nextTransportId;
|
|
155
|
+
private _resolvePromises;
|
|
156
|
+
private _rejectPromises;
|
|
157
|
+
}
|
|
158
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare enum errorCodes {
|
|
2
|
+
timeout = 1,
|
|
3
|
+
transportClosed = 2,
|
|
4
|
+
clientDisconnected = 3,
|
|
5
|
+
clientClosed = 4,
|
|
6
|
+
clientConnectToken = 5,
|
|
7
|
+
clientRefreshToken = 6,
|
|
8
|
+
subscriptionUnsubscribed = 7,
|
|
9
|
+
subscriptionSubscribeToken = 8,
|
|
10
|
+
subscriptionRefreshToken = 9,
|
|
11
|
+
transportWriteError = 10,
|
|
12
|
+
connectionClosed = 11,
|
|
13
|
+
badConfiguration = 12
|
|
14
|
+
}
|
|
15
|
+
export declare enum connectingCodes {
|
|
16
|
+
connectCalled = 0,
|
|
17
|
+
transportClosed = 1,
|
|
18
|
+
noPing = 2,
|
|
19
|
+
subscribeTimeout = 3,
|
|
20
|
+
unsubscribeError = 4
|
|
21
|
+
}
|
|
22
|
+
export declare enum disconnectedCodes {
|
|
23
|
+
disconnectCalled = 0,
|
|
24
|
+
unauthorized = 1,
|
|
25
|
+
badProtocol = 2,
|
|
26
|
+
messageSizeLimit = 3
|
|
27
|
+
}
|
|
28
|
+
export declare enum subscribingCodes {
|
|
29
|
+
subscribeCalled = 0,
|
|
30
|
+
transportClosed = 1
|
|
31
|
+
}
|
|
32
|
+
export declare enum unsubscribedCodes {
|
|
33
|
+
unsubscribeCalled = 0,
|
|
34
|
+
unauthorized = 1,
|
|
35
|
+
clientClosed = 2
|
|
36
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Centrifuge, UnauthorizedError } from './centrifuge';
|
|
2
|
+
import { Subscription } from './subscription';
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export * from "./codes";
|
|
5
|
+
declare class CentrifugeProtobuf extends Centrifuge {
|
|
6
|
+
protected _formatOverride(): void;
|
|
7
|
+
}
|
|
8
|
+
export { CentrifugeProtobuf as Centrifuge, UnauthorizedError, Subscription };
|