@devanachat/sdk 0.12.0 → 0.13.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.
@@ -6,7 +6,16 @@ import { Envelope } from "./protocol";
6
6
  export interface WebSocketClientOptions {
7
7
  url: string;
8
8
  token: string;
9
+ /**
10
+ * Time an attempt may take until the socket opens. Default is 10 seconds.
11
+ */
9
12
  connectingTimeoutMs?: number;
13
+ /**
14
+ * Time to wait for `Session` once the socket is open. The server may hold a connection in a queue before
15
+ * authenticating it when many clients connect at once, so this is longer than `connectingTimeoutMs`.
16
+ * Default is 60 seconds.
17
+ */
18
+ sessionTimeoutMs?: number;
10
19
  awaitQueueSendDelayMs?: number;
11
20
  stateTracking?: boolean;
12
21
  queryParams?: Record<string, string>;
@@ -27,17 +36,28 @@ export interface WebSocketClientOptions {
27
36
  /**
28
37
  * Automatic reconnection. After the connection is lost (error, connecting timeout, missing pong
29
38
  * or closure with a code other than 1000) the client retries indefinitely, waiting between attempts
30
- * with an exponential backoff. Calling `disconnect()` stops retrying until the next `connect()`.
39
+ * a random time up to an exponentially growing limit. Calling `disconnect()` stops retrying until
40
+ * the next `connect()`.
31
41
  */
32
42
  reconnect?: {
33
43
  /**
34
- * Delay before the first retry; each subsequent one doubles it. Default is 1 second.
44
+ * Limit of the first delay after a lost connection; each subsequent one doubles it. Default is 1 second.
35
45
  */
36
46
  minDelayMs?: number;
47
+ /**
48
+ * Limit of the first delay when the server closed the connection (close code 1001, 1012 or 1013, or after
49
+ * a `Bye`); each subsequent one doubles it. Default is 5 seconds. It wins over a lower `maxDelayMs`.
50
+ */
51
+ serverCloseMinDelayMs?: number;
37
52
  /**
38
53
  * Upper limit of the delay between retries. Default is 30 seconds.
39
54
  */
40
55
  maxDelayMs?: number;
56
+ /**
57
+ * Time an authenticated connection has to last for the next loss to start the backoff over.
58
+ * Default is 30 seconds.
59
+ */
60
+ stableConnectionMs?: number;
41
61
  };
42
62
  }
43
63
  declare enum WebSocketChatClientEvent {
@@ -68,14 +88,20 @@ export declare class WebSocketChatClient extends AbstractChatClient<Pick<WebSock
68
88
  protected reconnectEnabled: boolean;
69
89
  protected reconnectTimeoutId?: any;
70
90
  protected reconnectAttempts: number;
91
+ protected serverClosedSinceStable: boolean;
92
+ protected byeReceived: boolean;
93
+ protected byeRetryAfterMs?: number;
94
+ protected stableConnectionTimeoutId?: any;
71
95
  constructor(options: WebSocketClientOptions);
72
96
  connect(): Promise<void>;
73
97
  disconnect(): void;
74
98
  send<CommandType extends keyof CommandsMap>(commandType: CommandType, commandData: CommandRequest<CommandType>): Promise<CommandResult<CommandResponse<CommandType>>>;
75
99
  get isReady(): boolean;
76
100
  private openSocket;
101
+ private startConnectingTimeout;
77
102
  private sendEnvelope;
78
103
  private onMessage;
104
+ private onBye;
79
105
  private onClose;
80
106
  /**
81
107
  * Abandon the current socket without waiting for its close event (which
@@ -89,6 +115,7 @@ export declare class WebSocketChatClient extends AbstractChatClient<Pick<WebSock
89
115
  */
90
116
  private releaseSocket;
91
117
  private scheduleReconnect;
118
+ private resetBackoff;
92
119
  private cancelScheduledReconnect;
93
120
  /**
94
121
  * Resolve (or reject, when an error is given) a pending connect() promise.
@@ -1,6 +1,7 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
2
  import { MessagePoll } from "../MessagePoll";
3
3
  import { SendableEmbed } from "../MessageEmbed";
4
+ import { MessageMentions } from "../Message";
4
5
  export interface CreateMessage {
5
6
  location: ChatLocation;
6
7
  content: string;
@@ -16,4 +17,5 @@ export interface CreateMessage {
16
17
  interactionId?: string;
17
18
  /** Bots only: the id of the room member the message is shown to; it is not stored and resolves with `Ok` */
18
19
  ephemeralFor?: string;
20
+ allowedMentions?: MessageMentions;
19
21
  }
@@ -1,4 +1,5 @@
1
1
  import { LeaveReason } from "../LeaveReason";
2
2
  export interface Bye {
3
3
  reason: LeaveReason;
4
+ retryAfterMs?: number;
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devanachat/sdk",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "TypeScript/JavaScript SDK for the Devana chat platform: WebSocket and Web API clients, state tracking, permissions and files.",
5
5
  "keywords": [
6
6
  "devana",