diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-12 21:09:29 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-12 21:09:29 +0200 |
commit | d50073fc41fc7d69d3dab9a2858158320983329b (patch) | |
tree | c4507ebe83019292807f5a4cf10fc8a522334e2a /gateway/src/events/Message.ts | |
parent | Merge pull request #348 from AlTech98/fix-cdn-upload (diff) | |
download | server-d50073fc41fc7d69d3dab9a2858158320983329b.tar.xz |
:art: remove long relatives paths -> short module paths
Diffstat (limited to 'gateway/src/events/Message.ts')
-rw-r--r-- | gateway/src/events/Message.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gateway/src/events/Message.ts b/gateway/src/events/Message.ts index a8bf5d78..5c6bd2fc 100644 --- a/gateway/src/events/Message.ts +++ b/gateway/src/events/Message.ts @@ -1,10 +1,10 @@ -import WebSocket, { Data } from "../util/WebSocket"; +import WebSocket, { Data } from "@fosscord/gateway/util/WebSocket"; var erlpack: any; try { erlpack = require("erlpack"); } catch (error) {} import OPCodeHandlers from "../opcodes"; -import { Payload, CLOSECODES, OPCODES } from "../util/Constants"; +import { Payload, CLOSECODES, OPCODES } from "@fosscord/gateway/util/Constants"; import { instanceOf, Tuple } from "lambert-server"; import { check } from "../opcodes/instanceOf"; import WS from "ws"; @@ -20,8 +20,10 @@ export async function Message(this: WebSocket, buffer: WS.Data) { // TODO: compression var data: Payload; - if (this.encoding === "etf" && buffer instanceof Buffer) data = erlpack.unpack(buffer); - else if (this.encoding === "json" && typeof buffer === "string") data = JSON.parse(buffer); + if (this.encoding === "etf" && buffer instanceof Buffer) + data = erlpack.unpack(buffer); + else if (this.encoding === "json" && typeof buffer === "string") + data = JSON.parse(buffer); else return; check.call(this, PayloadSchema, data); @@ -41,6 +43,7 @@ export async function Message(this: WebSocket, buffer: WS.Data) { return await OPCodeHandler.call(this, data); } catch (error) { console.error(error); - if (!this.CLOSED && this.CLOSING) return this.close(CLOSECODES.Unknown_error); + if (!this.CLOSED && this.CLOSING) + return this.close(CLOSECODES.Unknown_error); } } |