mirror of https://github.com/embarklabs/embark.git
Websocket support
This commit is contained in:
parent
586e7c7bbc
commit
9b37f807df
|
@ -82,9 +82,9 @@ Blockchain.prototype.setupProxy = function(){
|
|||
let ipcObject = new Ipc({ipcRole: 'client'});
|
||||
|
||||
proxy.serve(ipcObject, this.config.rpcHost, this.config.rpcPort, false);
|
||||
// proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true);
|
||||
proxy.serve(ipcObject, this.config.wsHost, this.config.wsPort, true);
|
||||
this.config.rpcPort += 10;
|
||||
//this.config.wsPort += 10;
|
||||
this.config.wsPort += 10;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ exports.serve = function(ipc, host, port, ws){
|
|||
let proxy = httpProxy.createProxyServer({
|
||||
target: {
|
||||
host: host,
|
||||
port: port + 10,
|
||||
ws: ws
|
||||
}
|
||||
port: port + 10
|
||||
},
|
||||
ws: ws
|
||||
});
|
||||
|
||||
proxy.on('proxyRes', (proxyRes) => {
|
||||
|
@ -32,7 +32,7 @@ exports.serve = function(ipc, host, port, ws){
|
|||
delete commList[jsonO.id];
|
||||
}
|
||||
} catch(e){
|
||||
//
|
||||
//
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -54,13 +54,16 @@ exports.serve = function(ipc, host, port, ws){
|
|||
}
|
||||
});
|
||||
|
||||
if(ws){
|
||||
proxy.ws(req, res);
|
||||
} else {
|
||||
if(!ws){
|
||||
proxy.web(req, res);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if(ws){
|
||||
server.on('upgrade', function (req, socket, head) {
|
||||
proxy.ws(req, socket, head);
|
||||
});
|
||||
}
|
||||
|
||||
server.listen(port);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue