Has anyone worked with this? I am trying to make a connection that works similar to Meteor’s connection. I have something that looks as follows
// common
Cylon.connections = new Mongo.Collection('cylon_connections');
// server
Cylon.connections._ensureIndex({ name: 1 }, { unique: true });
CylonConnection = function (name) {
let future = new Future();
let socket = new net.Socket();
socket._name = name;
this.connections.upsert({ name: socket._name }, {
$set: {
'connection.status': 'connecting',
'connection.reason': null,
'connection.retryCount': 0
},
$setOnInsert: {
messages: []
}
});
socket.addListener('connect', Meteor.bindEnvironment(() => {
this.connections.update({
$set: { 'connection.status': 'connected' },
$unset: { 'connection.reason': null }
});
future.return();
}));
future.wait();
}
Is this how this is done within meteor? What is the appropriate way to handle it?