Selaa lähdekoodia

use external http

master
peter 3 vuotta sitten
vanhempi
commit
e0bd76d7cc
2 muutettua tiedostoa jossa 7 lisäystä ja 3 poistoa
  1. 6
    3
      src/Backend.ts
  2. 1
    0
      src/Types.ts

+ 6
- 3
src/Backend.ts Näytä tiedosto

10
     InterfaceT extends T.RPCInterface = T.RPCInterface,
10
     InterfaceT extends T.RPCInterface = T.RPCInterface,
11
 > {
11
 > {
12
 
12
 
13
-    private ws = http.createServer()
14
     private pio = PromiseIO.createServer()
13
     private pio = PromiseIO.createServer()
15
     private visibility: T.Visibility
14
     private visibility: T.Visibility
16
     private closeHandler: T.CloseHandler
15
     private closeHandler: T.CloseHandler
28
     constructor(
27
     constructor(
29
         private port: number,
28
         private port: number,
30
         private exporters: T.ExporterArray<InterfaceT> = [],
29
         private exporters: T.ExporterArray<InterfaceT> = [],
31
-        conf: T.ServerConf<InterfaceT> = {}
30
+        private conf: T.ServerConf<InterfaceT> = {},
31
+        private ws = http.createServer()
32
     ) {
32
     ) {
33
         if (!conf.visibility) this.visibility = "0.0.0.0"
33
         if (!conf.visibility) this.visibility = "0.0.0.0"
34
 
34
 
67
             \n`+ badRPC.toString() + `
67
             \n`+ badRPC.toString() + `
68
             \n>------------OFFENDING RPC`)
68
             \n>------------OFFENDING RPC`)
69
         }
69
         }
70
+
71
+        
70
         this.startWebsocket()
72
         this.startWebsocket()
71
     }
73
     }
72
 
74
 
81
                 this.initRPCs(socket)
83
                 this.initRPCs(socket)
82
             })
84
             })
83
 
85
 
84
-            this.pio.listen(this.port)
86
+            if(this.conf.selfStart == null || this.conf.selfStart == true)
87
+                this.pio.listen(this.port)
85
 
88
 
86
         } catch (e) {
89
         } catch (e) {
87
             this.errorHandler(this.pio, e, 'system', [])
90
             this.errorHandler(this.pio, e, 'system', [])

+ 1
- 0
src/Types.ts Näytä tiedosto

28
 export type ConnectedSocket<T extends RPCInterface = RPCInterface> = RPCSocket & AsyncIfc<T>
28
 export type ConnectedSocket<T extends RPCInterface = RPCInterface> = RPCSocket & AsyncIfc<T>
29
 
29
 
30
 export type ServerConf<InterfaceT extends RPCInterface> = {
30
 export type ServerConf<InterfaceT extends RPCInterface> = {
31
+    selfStart?: boolean
31
     accessFilter?: AccessFilter<InterfaceT>
32
     accessFilter?: AccessFilter<InterfaceT>
32
     connectionHandler?: ConnectionHandler
33
     connectionHandler?: ConnectionHandler
33
     errorHandler?: ErrorHandler
34
     errorHandler?: ErrorHandler

Loading…
Peruuta
Tallenna