forked from engineering/cloudservices
logging
parent
fb3ec73898
commit
60f8c78180
|
@ -1,35 +1,36 @@
|
||||||
import net from 'net';
|
import net from 'net';
|
||||||
import { Client } from '.';
|
import { Client } from '.';
|
||||||
|
|
||||||
export default class Context {
|
export default class Context {
|
||||||
public socket: net.Socket;
|
public socket: net.Socket;
|
||||||
|
|
||||||
public client: Client;
|
public client: Client;
|
||||||
|
|
||||||
public data: {
|
public data: {
|
||||||
username: string,
|
username: string,
|
||||||
endpoint: string,
|
endpoint: string,
|
||||||
message?: string,
|
message?: string,
|
||||||
additionalData?: object,
|
additionalData?: object,
|
||||||
HMAC: string,
|
HMAC: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(socket: net.Socket, data: string, client: Client) {
|
constructor(socket: net.Socket, data: string, client: Client) {
|
||||||
const parsed: { Username: string, Type: string, Message?: string, Data?: object, HMAC: string } = JSON.parse(data);
|
const parsed: { Username: string, Type: string, Message?: string, Data?: object, HMAC: string } = JSON.parse(data);
|
||||||
|
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.data = {
|
this.data = {
|
||||||
username: parsed.Username,
|
username: parsed.Username,
|
||||||
endpoint: parsed.Type,
|
endpoint: parsed.Type,
|
||||||
message: parsed.Message,
|
message: parsed.Message,
|
||||||
additionalData: parsed.Data,
|
additionalData: parsed.Data,
|
||||||
HMAC: parsed.HMAC,
|
HMAC: parsed.HMAC,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public send(v: string) {
|
public send(v: string) {
|
||||||
this.socket.write(`${v.toString()}\n`);
|
console.log('writing or whateva');
|
||||||
this.socket.destroy();
|
this.socket.write(`${v.toString()}\n`, (err) => console.error(err));
|
||||||
}
|
this.socket.destroy();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue