cloudstorm 0.4.0 → 0.4.1

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.
@@ -1,10 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from "events";
3
- import zlib from "zlib-sync";
4
- import WebSocket from "ws";
5
3
  import RatelimitBucket from "./RatelimitBucket";
6
4
  interface BWSEvents {
7
- error: [Error | string];
8
5
  ws_open: [];
9
6
  ws_close: [number, string];
10
7
  ws_message: [import("../Types").IGatewayMessage];
@@ -30,58 +27,24 @@ interface BetterWs {
30
27
  * Helper Class for simplifying the websocket connection to Discord.
31
28
  */
32
29
  declare class BetterWs extends EventEmitter {
33
- ws: WebSocket;
30
+ encoding: "etf" | "json";
31
+ compress: boolean;
32
+ address: string;
33
+ options: import("../Types").IClientWSOptions;
34
34
  wsBucket: RatelimitBucket;
35
35
  presenceBucket: RatelimitBucket;
36
- zlibInflate: zlib.Inflate | null;
37
- options: import("../Types").IClientWSOptions;
38
- compress: boolean;
39
- static readonly default: typeof BetterWs;
40
- /**
41
- * Create a new BetterWs instance.
42
- */
43
- constructor(address: string, options?: import("../Types").IClientWSOptions);
44
- /**
45
- * Get the raw websocket connection currently used.
46
- */
47
- get rawWs(): WebSocket;
48
- /**
49
- * Add eventlisteners to a passed websocket connection.
50
- * @param ws Websocket.
51
- */
52
- private bindWs;
53
- /**
54
- * Create a new websocket connection if the old one was closed/destroyed.
55
- * @param address Address to connect to.
56
- * @param options Options used by the websocket connection.
57
- */
58
- recreateWs(address: string, options?: import("../Types").IClientWSOptions): void;
59
- /**
60
- * Called upon opening of the websocket connection.
61
- */
62
- private onOpen;
63
- /**
64
- * Called once a websocket message is received,
65
- * uncompresses the message using zlib and parses it via Erlpack or JSON.parse.
66
- * @param message Message received by websocket.
67
- */
68
- private onMessage;
69
- /**
70
- * Called when the websocket connection closes for some reason.
71
- * @param code Websocket close code.
72
- * @param reason Reason of the close if any.
73
- */
74
- private onClose;
75
- /**
76
- * Send a message to the Discord gateway.
77
- * @param data Data to send.
78
- */
79
- sendMessage(data: any): Promise<void>;
80
- /**
81
- * Close the current websocket connection.
82
- * @param code Websocket close code to use.
83
- * @param reason Reason of the disconnect.
84
- */
85
- close(code?: number, reason?: string): Promise<void>;
36
+ private _socket;
37
+ private _internal;
38
+ private _connecting;
39
+ constructor(address: string, options: import("../Types").IClientWSOptions);
40
+ get status(): 1 | 2 | 3 | 4;
41
+ connect(): Promise<void>;
42
+ close(): Promise<void>;
43
+ sendMessage(data: import("../Types").IWSMessage): Promise<void>;
44
+ private _write;
45
+ private _onError;
46
+ private _onClose;
47
+ private _onReadable;
48
+ private _processFrame;
86
49
  }
87
50
  export = BetterWs;