This commit is contained in:
Daniel Hübleitner
2019-09-18 01:19:33 +02:00
parent 41a5d14fd8
commit 34ec2d0244
3 changed files with 9 additions and 7 deletions
+3 -4
View File
@@ -5,9 +5,8 @@ import * as uuid from "uuid/v4"
import { Socket } from "./RPCSocketServer"
type rpcType = 'hook' | 'unhook' | 'call'
type visibility = 'public' | 'private'
export type Outcome = "Success" | "Error"
export type Visibility = "127.0.0.1" | "0.0.0.0"
/* Responses */
export class Response{
@@ -56,7 +55,6 @@ export interface RPCExporter{
type baseRPC = {
type: rpcType
name: string
visibility: visibility
}
type hookRPC = baseRPC & {
@@ -211,6 +209,7 @@ export class RPCSocketServer{
constructor(
private port:number,
private rpcExporters: RPCExporter[] = [],
private visibility: Visibility = "127.0.0.1",
private conf: RPCSocketConf = {
errorHandler: (socket:Socket) => (error:any) => { socket.destroy(); console.error(error) },
closeHandler: (socket:Socket) => () => { console.log("Socket closing") },
@@ -228,7 +227,7 @@ export class RPCSocketServer{
socket.on('close', this.conf.closeHandler(socket))
this.initApis(socket)
})
this.wsServer.listen(this.port)
this.wsServer.listen(this.port, this.visibility)
}catch(e){
//@ts-ignore
this.errorHandler(undefined)("Unable to connect to socket")