set protocol when connecting but this time for real
This commit is contained in:
+7
-1
@@ -16,6 +16,7 @@ export class RPCSocket<Ifc extends T.RPCInterface = T.RPCInterface> implements I
|
||||
return await socket.connect(sesame)
|
||||
}
|
||||
|
||||
private protocol: 'http:' | 'https:'
|
||||
private socket: I.Socket
|
||||
private handlers : {
|
||||
[name in string]: T.AnyFunction[]
|
||||
@@ -33,6 +34,11 @@ export class RPCSocket<Ifc extends T.RPCInterface = T.RPCInterface> implements I
|
||||
*/
|
||||
constructor(public port:number, private server: string, private conf:T.SocketConf = { tls: false }){
|
||||
Object.defineProperty(this, 'socket', {value: undefined, writable: true})
|
||||
if(conf.tls){
|
||||
this.protocol = "https:"
|
||||
}else{
|
||||
this.protocol = "http:"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +145,7 @@ export class RPCSocket<Ifc extends T.RPCInterface = T.RPCInterface> implements I
|
||||
public async connect( sesame?: string ) : Promise<T.ConnectedSocket<Ifc>> {
|
||||
|
||||
try{
|
||||
this.socket = await PromiseIOClient.connect(this.port, this.server, /*this.conf.tls?this.conf.tls:false*/)
|
||||
this.socket = await PromiseIOClient.connect(this.port, this.server, this.protocol)
|
||||
}catch(e){
|
||||
this.handlers['error'].forEach(h => h(e))
|
||||
throw e
|
||||
|
||||
Reference in New Issue
Block a user