Kaynağa Gözat

use external http

master
peter 4 yıl önce
ebeveyn
işleme
e0bd76d7cc
2 değiştirilmiş dosya ile 7 ekleme ve 3 silme
  1. 6
    3
      src/Backend.ts
  2. 1
    0
      src/Types.ts

+ 6
- 3
src/Backend.ts Dosyayı Görüntüle

@@ -10,7 +10,6 @@ export class RPCServer<
10 10
     InterfaceT extends T.RPCInterface = T.RPCInterface,
11 11
 > {
12 12
 
13
-    private ws = http.createServer()
14 13
     private pio = PromiseIO.createServer()
15 14
     private visibility: T.Visibility
16 15
     private closeHandler: T.CloseHandler
@@ -28,7 +27,8 @@ export class RPCServer<
28 27
     constructor(
29 28
         private port: number,
30 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 33
         if (!conf.visibility) this.visibility = "0.0.0.0"
34 34
 
@@ -67,6 +67,8 @@ export class RPCServer<
67 67
             \n`+ badRPC.toString() + `
68 68
             \n>------------OFFENDING RPC`)
69 69
         }
70
+
71
+        
70 72
         this.startWebsocket()
71 73
     }
72 74
 
@@ -81,7 +83,8 @@ export class RPCServer<
81 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 89
         } catch (e) {
87 90
             this.errorHandler(this.pio, e, 'system', [])

+ 1
- 0
src/Types.ts Dosyayı Görüntüle

@@ -28,6 +28,7 @@ export type ExporterArray<InterfaceT extends RPCInterface = RPCInterface> = I.RP
28 28
 export type ConnectedSocket<T extends RPCInterface = RPCInterface> = RPCSocket & AsyncIfc<T>
29 29
 
30 30
 export type ServerConf<InterfaceT extends RPCInterface> = {
31
+    selfStart?: boolean
31 32
     accessFilter?: AccessFilter<InterfaceT>
32 33
     connectionHandler?: ConnectionHandler
33 34
     errorHandler?: ErrorHandler

Loading…
İptal
Kaydet