/** * Logs out, terminates the connection to Discord, and destroys the client. * @returns {void} */ destroy() { super.destroy(); this.ws.destroy(); this.token = null; }
nest('blob.sync.url', function (link) { const config = api.config.sync.load() const prefix = config.blobsPrefix != null ? config.blobsPrefix : `http://localhost:${config.ws.port}/blobs/get` if (typeof link !== 'object') { link = ref.parseLink(link) } return linkToUrl(prefix, link) })
sendMessage(message) { if (message.unsubscribe && this.messageQueue.find(m => m.messageId === message.unsubscribe)) { this.messageQueue = this.messageQueue.filter(m => m.messageId !== message.unsubscribe); } else { this.messageQueue.push(message); } setTimeout(async () => { await this.initSocket(); this.ws.sendQueue(); }, 100); }
connect () { this.ws = new WebSocket(config.serverUri); this.ws.onopen = () => this.onConnectionOpen(); this.ws.onmessage = (event) => this.onConnectionMessage(event); this.ws.onclose = () => this.onConnectionClose(); this.ws.sendJSON = (obj) => this.ws.send(JSON.stringify(obj)); this.state.status = States.CONNECTING; }
/** * The Shard this Guild belongs to. * @type {WebSocketShard} * @readonly */ get shard() { return this.client.ws.shards.get(this.shardID); }
componentWillUnmount () { this.ws.close(); }
dispatch (key, value) { this.ws.sendJSON({ key, value, }); }
dispatch (key, value) { this.ws.sendJSON({ key, value, }); }
connect () { this.ws = new WebSocket(config.serverUri); this.ws.onopen = () => this.onConnectionOpen(); this.ws.onmessage = (event) => this.onConnectionMessage(event); this.ws.onclose = () => this.onConnectionClose(); this.ws.sendJSON = (obj) => this.ws.send(JSON.stringify(obj)); this.state.status = States.CONNECTING; }
componentWillUnmount () { this.ws.close(); }