Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pro.connect = function(tracer, cb) {
tracer && tracer.info('client', __filename, 'connect', 'ws-mailbox try to connect');
if (this.connected) {
tracer && tracer.error('client', __filename, 'connect', 'mailbox has already connected');
cb(new Error('mailbox has already connected.'));
return;
}
this.socket = wsClient.connect('ws://' + this.host + ':' + this.port);
//this.socket = wsClient.connect(this.host + ':' + this.port, {'force new connection': true, 'reconnect': false});
var self = this;
this.socket.on('message', function(data, flags) {
try {
// console.log("ws rpc client received message = " + data);
var msg = data;
msg = JSON.parse(msg);
if (msg.body instanceof Array) {
processMsgs(self, msg.body);
} else {
processMsg(self, msg.body);
}
} catch (e) {
it('should connect', function (done) {
connection = ws.connect(url);
connection.on('open', function () {
done();
});
});
s.listen(function(){
var c = ws.connect('wss://localhost:9004', function(){
c.send('A');
});
});
});
s.listen(function(){
var c = ws.connect('ws://localhost:9003', function(){
c.send('A');
});
});
});
window.connectToSocket = function () {
var socket = ws.connect('ws://localhost:8081/devtools');
socket.onmessage = evt => {
if (evt.data === 'attach:agent') {
initialize(socket);
}
};
socket.onerror = function (err) {
onDisconnected();
console.log('Error with websocket connection', err);
};
socket.onclose = function () {
onDisconnected();
console.log('Connection to RN closed');
};
}
}catch(e){
that.proxyServer.destroy();
console.log(e);
console.log(data);
return;
}
if(data.name === "id"){
cb(void(0),data.data);
console.log("your servers name is: "+data.data)
}else{
console.log('received data: ' + data);
that.handleSocketMessage(data);
}
})
console.log('connecting websocket');
this.proxyWS = ws.connect("ws://localhost:3000/ws/websocket",function(){
console.log("connected as websocket: "+arguments)
});
this.proxyWS.on("error",function(e){
console.log('ws error');
console.log(e.stack);
})
this.proxyWS.on("message",function(data){
console.log('ws message: ' + data);
that.proxyServer.write(data+"\u00B6");
})
}
($module)['connect-to-interactor'] = B8['%make-method']('connect-to-interactor', function B97(evaluator__98, url__99) {
var connection__100 = B69['connect'](url__99);
{
B8['get-setter'](evaluator__98, 'connection', connection__100);
{
var B101 = connection__100;
{
var B102 = 'message';
{
var B103 = B8['curry'](B68['handle-message'], evaluator__98);
return(B101['on'](B102, B103));
}
}
}
}
}, false, ($module)[''], ($module)['connect-to-interactor']);
{
function CexIOStreamer(symbol, callback, errback) {
var self = this;
this.socket = ws.connect('wss://ws.cex.io/ws');
this.socket.on('open', function (data) {
self.socket.send(JSON.stringify({
e: "subscribe",
rooms: ["tickers"]
}));
});
this.socket.on('message', function (message){
var payload = JSON.parse(message);
if ((payload.e !== "tick") ||
(payload.data.symbol2 !== 'USD')) {
return;
}
if ((payload.data.symbol1 === 'LTC' && symbol === 'LTCUSD') ||