mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-20 01:18:52 +00:00
fix: simulator proxy with ws
This commit is contained in:
parent
2613e6d683
commit
5968eef349
@ -86,6 +86,10 @@ class Simulator {
|
|||||||
|
|
||||||
if(useProxy){
|
if(useProxy){
|
||||||
let ipcObject = new Ipc({ipcRole: 'client'});
|
let ipcObject = new Ipc({ipcRole: 'client'});
|
||||||
|
if (this.blockchainConfig.wsRPC) {
|
||||||
|
return new Proxy(ipcObject).serve(host, port, true, this.blockchainConfig.wsOrigins, []);
|
||||||
|
}
|
||||||
|
|
||||||
new Proxy(ipcObject).serve(host, port, false);
|
new Proxy(ipcObject).serve(host, port, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,9 @@ function pingEndpoint(host, port, type, protocol, origin, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSuccess = (req, closeMethod, event) => {
|
const handleSuccess = (req, closeMethod, event) => {
|
||||||
req.once(event, () => { handleEvent(req, closeMethod); });
|
req.once(event, () => {
|
||||||
|
handleEvent(req, closeMethod);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRequest = (req, closeMethod, event) => {
|
const handleRequest = (req, closeMethod, event) => {
|
||||||
@ -136,10 +138,8 @@ function pingEndpoint(host, port, type, protocol, origin, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (type === 'ws') {
|
if (type === 'ws') {
|
||||||
const req = new (require('ws'))(
|
const url = `${protocol === 'https' ? 'wss' : 'ws'}://${_host}:${port}/`;
|
||||||
`${protocol === 'https' ? 'wss' : 'ws'}://${_host}:${port}/`,
|
const req = new (require('ws'))(url, origin ? {origin} : {});
|
||||||
origin ? {origin} : {}
|
|
||||||
);
|
|
||||||
handleRequest(req, 'close', 'open');
|
handleRequest(req, 'close', 'open');
|
||||||
} else {
|
} else {
|
||||||
const headers = origin ? {Origin: origin} : {};
|
const headers = origin ? {Origin: origin} : {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user