Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
a.list(web.opt.node.src).each(function(url){
var toe = toes.create(url);
web.node.cons[url] = toe;
toe.on('error', function(e){ console.log('ut-oh', e) }); // need to add this before the connection event.
toe.on('connection', function(){
toe.writable = true;
toe.mid = url;
toe.write(a.text.ify(a.com.meta({
what: {auth: web.opt.node.key, to: url}
,where: {mid: web.opt.node.mid}
})));
state.con(toe);
});
});
}
a.list(web.opt.node.src).each(function(url){
var toe = toes.create(url);
web.node.cons[url] = toe;
toe.on('error', function(e){ console.log('ut-oh', e) }); // need to add this before the connection event.
toe.on('connection', function(){
toe.writable = true;
toe.mid = url;
toe.write(a.text.ify(a.com.meta({
what: {auth: web.opt.node.key, to: url}
,where: {mid: web.opt.node.mid}
})));
state.con(toe);
});
});
}
return function(conn) {
var clientId = ++clientIds;
console.log(util.format('New Client: [%d]', clientId) + '\n');
var meteor = sjsc.create('http://localhost:' + meteorPort + '/sockjs');
closeBrowserConnection = _.once(conn.close.bind(conn));
conn.on('data', function(message) {
meteor.write(message);
printDdp('client', message, clientId);
});
conn.on('close', meteor.close);
meteor.on('data', function(message) {
conn.write(message);
printDdp('server', message, clientId);
});
meteor.on('error', function() {
closeBrowserConnection();
meteor.close();
var createClient = function (uri, options: any = {}) {
var sjsoptions: any = {};
sjsoptions.prefix = options.prefix ? options.prefix : undefined;
var socket;
if (Eureca.Util.isNodejs) {
socket = require('sockjs-client').create(uri + sjsoptions.prefix);
} else {
socket = new SockJS(uri);
}
var client = new Socket(socket);
return client;
}
Transport.register('sockjs', '/js/sockjs-0.3.min.js', createClient, createServer);