|
@@ -16,6 +16,7 @@ export class RPCSocket<Ifc extends T.RPCInterface = T.RPCInterface> implements I
|
16
|
16
|
return await socket.connect(sesame)
|
17
|
17
|
}
|
18
|
18
|
|
|
19
|
+ private protocol: 'http:' | 'https:'
|
19
|
20
|
private socket: I.Socket
|
20
|
21
|
private handlers : {
|
21
|
22
|
[name in string]: T.AnyFunction[]
|
|
@@ -33,6 +34,11 @@ export class RPCSocket<Ifc extends T.RPCInterface = T.RPCInterface> implements I
|
33
|
34
|
*/
|
34
|
35
|
constructor(public port:number, private server: string, private conf:T.SocketConf = { tls: false }){
|
35
|
36
|
Object.defineProperty(this, 'socket', {value: undefined, writable: true})
|
|
37
|
+ if(conf.tls){
|
|
38
|
+ this.protocol = "https:"
|
|
39
|
+ }else{
|
|
40
|
+ this.protocol = "http:"
|
|
41
|
+ }
|
36
|
42
|
}
|
37
|
43
|
|
38
|
44
|
/**
|
|
@@ -139,7 +145,7 @@ export class RPCSocket<Ifc extends T.RPCInterface = T.RPCInterface> implements I
|
139
|
145
|
public async connect( sesame?: string ) : Promise<T.ConnectedSocket<Ifc>> {
|
140
|
146
|
|
141
|
147
|
try{
|
142
|
|
- this.socket = await PromiseIOClient.connect(this.port, this.server, /*this.conf.tls?this.conf.tls:false*/)
|
|
148
|
+ this.socket = await PromiseIOClient.connect(this.port, this.server, this.protocol)
|
143
|
149
|
}catch(e){
|
144
|
150
|
this.handlers['error'].forEach(h => h(e))
|
145
|
151
|
throw e
|