From ea4a9931821d2b2199c53b9283c4d1897ee718df Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 22 Jul 2022 20:58:32 -0400 Subject: [PATCH] *Refactor RPC connection to its own class --- src/rpc.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rpc.ts b/src/rpc.ts index 4e62b7a..9196ac3 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -244,7 +244,14 @@ export async function start() { jsonServer = new jayson.Server(rpcMethods, { useContext: true }); - (await getDHT("server")).on("connection", (socket: any) => { + (await getDHT("server")).on("connection", RPCConnection.handleRequest); +} + +class RPCConnection { + private _socket: any; + private _process = false; + constructor(socket: any) { + this._socket = socket; socket.rawStream._ondestroy = () => false; let isRpc = false;