mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-21 04:25:27 -04:00
Expose strongly typed send function.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "revolt.js",
|
||||
"version": "3.0.3-alpha.8",
|
||||
"version": "3.0.3-alpha.9",
|
||||
"main": "dist/index.js",
|
||||
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
|
||||
"author": "Paul Makles <insrt.uk>",
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ export { default as User } from './objects/User';
|
||||
export { default as Message } from './objects/Message';
|
||||
export { default as Channel, SavedMessagesChannel, DirectMessageChannel, GroupChannel } from './objects/Channel';
|
||||
|
||||
export const LIBRARY_VERSION = '3.0.3-alpha.8';
|
||||
export const LIBRARY_VERSION = '3.0.3-alpha.9';
|
||||
|
||||
export const defaultConfig = {
|
||||
apiURL: 'https://api.revolt.chat',
|
||||
|
||||
@@ -31,6 +31,14 @@ export class WebSocketClient {
|
||||
}
|
||||
}
|
||||
|
||||
send(notification: ServerboundNotification) {
|
||||
if (!this.ws) return;
|
||||
|
||||
let data = JSON.stringify(notification);
|
||||
if (this.client.debug) console.debug('[<] PACKET', data);
|
||||
this.ws.send(data);
|
||||
}
|
||||
|
||||
connect(disallowReconnect?: boolean): Promise<void> {
|
||||
this.client.emit('connecting');
|
||||
|
||||
@@ -54,14 +62,9 @@ export class WebSocketClient {
|
||||
}
|
||||
|
||||
let ws = new WebSocket(this.client.configuration.ws);
|
||||
const send = (notification: ServerboundNotification) => {
|
||||
let data = JSON.stringify(notification);
|
||||
if (this.client.debug) console.debug('[<] PACKET', data);
|
||||
ws.send(data)
|
||||
};
|
||||
|
||||
ws.onopen = () => {
|
||||
send({ type: 'Authenticate', ...this.client.session as Auth.Session });
|
||||
this.send({ type: 'Authenticate', ...this.client.session as Auth.Session });
|
||||
};
|
||||
|
||||
let handle = async (msg: WebSocket.MessageEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user