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'});
|
let ipcObject = new Ipc({ipcRole: 'client'});
|
||||||
|
|
||||||
proxy.serve(ipcObject, this.config.rpcHost, this.config.rpcPort, false);
|
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.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({
|
let proxy = httpProxy.createProxyServer({
|
||||||
target: {
|
target: {
|
||||||
host: host,
|
host: host,
|
||||||
port: port + 10,
|
port: port + 10
|
||||||
|
},
|
||||||
ws: ws
|
ws: ws
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy.on('proxyRes', (proxyRes) => {
|
proxy.on('proxyRes', (proxyRes) => {
|
||||||
|
@ -54,13 +54,16 @@ exports.serve = function(ipc, host, port, ws){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ws){
|
if(!ws){
|
||||||
proxy.ws(req, res);
|
|
||||||
} else {
|
|
||||||
proxy.web(req, res);
|
proxy.web(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(ws){
|
||||||
|
server.on('upgrade', function (req, socket, head) {
|
||||||
|
proxy.ws(req, socket, head);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
server.listen(port);
|
server.listen(port);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue