Birb / BaseWebsocket
Class: BaseWebsocket
Hierarchy
-
BaseWebsocket
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new BaseWebsocket(client
, domain
)
Parameters
Name | Type |
---|---|
client | Birb |
domain | string |
Defined in
src/classes/ws/BaseWebsocket.ts:46
Properties
buffer
• Protected
buffer: any
The internal erlpack buffer.
Defined in
src/classes/ws/BaseWebsocket.ts:44
client
• client: Birb
The Birb client.
Defined in
src/classes/ws/BaseWebsocket.ts:24
domain
• domain: string
The websocket domain to connect to.
Defined in
src/classes/ws/BaseWebsocket.ts:28
encoding
• encoding: string
The encoding to use.
Defined in
src/classes/ws/BaseWebsocket.ts:40
status
• status: GatewayStatus
= Status.IDLE
The current websocket status.
Defined in
src/classes/ws/BaseWebsocket.ts:36
url
• url: URL
The URL to connect to.
Defined in
src/classes/ws/BaseWebsocket.ts:32
Methods
generateURL
▸ generateURL(): URL
Returns
Defined in
src/classes/ws/BaseWebsocket.ts:151
init
▸ Protected
init(): void
Initializes ZLib if supported.
Returns
void
Voids once ZLib is initialized.
Defined in
src/classes/ws/BaseWebsocket.ts:142
pack
▸ Protected
pack(data
): any
Packs data for sending to Discord. If the encoding is set to etf
, this method will use the zlib-sync
(npm install zlib-sync
) library to pack its etf
data. Otherwise, parses the JSON data to a string.
Parameters
Name | Type | Description |
---|---|---|
data | any | The data to pack. |
Returns
any
Hopefully, the data’s packed form.
Defined in
src/classes/ws/BaseWebsocket.ts:132
processPacket
▸ Protected
processPacket(data
): any
Attempts to process a packet by using ZLib to let Discord send packets in chunks. If ZLib is not yet installed (npm install zlib-sync
), this method will just pass the data through for unpacking (this.unpack()
).
Parameters
Name | Type | Description |
---|---|---|
data | any | The packet’s data. |
Returns
any
Hopefully, the packet’s JSON form.
Defined in
src/classes/ws/BaseWebsocket.ts:63
unpack
▸ Protected
unpack(data
, type?
): any
Unpacks a packet using the current encoding. If the encoding is set to etf
, this method will use the zlib-sync
(npm install zlib-sync
) library to unpack its etf
data. Otherwise, parses the data to normal JSON.
Parameters
Name | Type | Description |
---|---|---|
data | any | The packet’s data. |
type? | string | The packet’s encoding. |
Returns
any
Hopefully, the packet’s JSON form.
Defined in
src/classes/ws/BaseWebsocket.ts:109