diff --git a/src/class/Context.ts b/src/class/Context.ts index d219af6..6a12ff4 100644 --- a/src/class/Context.ts +++ b/src/class/Context.ts @@ -1,35 +1,36 @@ -import net from 'net'; -import { Client } from '.'; - -export default class Context { - public socket: net.Socket; - - public client: Client; - - public data: { - username: string, - endpoint: string, - message?: string, - additionalData?: object, - HMAC: string, - } - - constructor(socket: net.Socket, data: string, client: Client) { - const parsed: { Username: string, Type: string, Message?: string, Data?: object, HMAC: string } = JSON.parse(data); - - this.socket = socket; - this.client = client; - this.data = { - username: parsed.Username, - endpoint: parsed.Type, - message: parsed.Message, - additionalData: parsed.Data, - HMAC: parsed.HMAC, - }; - } - - public send(v: string) { - this.socket.write(`${v.toString()}\n`); - this.socket.destroy(); - } -} +import net from 'net'; +import { Client } from '.'; + +export default class Context { + public socket: net.Socket; + + public client: Client; + + public data: { + username: string, + endpoint: string, + message?: string, + additionalData?: object, + HMAC: string, + } + + constructor(socket: net.Socket, data: string, client: Client) { + const parsed: { Username: string, Type: string, Message?: string, Data?: object, HMAC: string } = JSON.parse(data); + + this.socket = socket; + this.client = client; + this.data = { + username: parsed.Username, + endpoint: parsed.Type, + message: parsed.Message, + additionalData: parsed.Data, + HMAC: parsed.HMAC, + }; + } + + public send(v: string) { + console.log('writing or whateva'); + this.socket.write(`${v.toString()}\n`, (err) => console.error(err)); + this.socket.destroy(); + } +}