use external http

This commit is contained in:
2020-08-07 18:38:26 +02:00
parent 2a67927306
commit e0bd76d7cc
2 changed files with 7 additions and 3 deletions
+6 -3
View File
@@ -10,7 +10,6 @@ export class RPCServer<
InterfaceT extends T.RPCInterface = T.RPCInterface,
> {
private ws = http.createServer()
private pio = PromiseIO.createServer()
private visibility: T.Visibility
private closeHandler: T.CloseHandler
@@ -28,7 +27,8 @@ export class RPCServer<
constructor(
private port: number,
private exporters: T.ExporterArray<InterfaceT> = [],
conf: T.ServerConf<InterfaceT> = {}
private conf: T.ServerConf<InterfaceT> = {},
private ws = http.createServer()
) {
if (!conf.visibility) this.visibility = "0.0.0.0"
@@ -67,6 +67,8 @@ export class RPCServer<
\n`+ badRPC.toString() + `
\n>------------OFFENDING RPC`)
}
this.startWebsocket()
}
@@ -81,7 +83,8 @@ export class RPCServer<
this.initRPCs(socket)
})
this.pio.listen(this.port)
if(this.conf.selfStart == null || this.conf.selfStart == true)
this.pio.listen(this.port)
} catch (e) {
this.errorHandler(this.pio, e, 'system', [])
+1
View File
@@ -28,6 +28,7 @@ export type ExporterArray<InterfaceT extends RPCInterface = RPCInterface> = I.RP
export type ConnectedSocket<T extends RPCInterface = RPCInterface> = RPCSocket & AsyncIfc<T>
export type ServerConf<InterfaceT extends RPCInterface> = {
selfStart?: boolean
accessFilter?: AccessFilter<InterfaceT>
connectionHandler?: ConnectionHandler
errorHandler?: ErrorHandler