Here is my basic package code, where I open two TCP sockets.
// server.es6
Galil._createConnection = function (name) {
check(name, String);
Galil.connections.upsert({ name: name }, {
$set: { status: 'disconnected' },
$setOnInsert: { messages: [] }
});
let socket = net.connect(Galil.config.connection, Meteor.bindEnvironment(function () {
Galil.connections.update({ name: name }, { $set: { status: 'connected' } });
}));
let setDisconnected = function () {
Galil.connections.update({ name: name }, {
$set: { status: 'disconnected' }
});
}
socket.addListener('end', Meteor.bindEnvironment(setDisconnected));
socket.addListener('close', Meteor.bindEnvironment(setDisconnected));
socket.addListener('error', Meteor.bindEnvironment(setDisconnected));
}
So in my hardware controller, I try unplugging it. I expect that this will cause the collection to update and set to disconnected. However, if it does, it takes a pretty considerable amount of time. Has anyone experienced this? What do?