You could create a custom module to filter outgoing messages and decide whether they should be ignored or not based on the client's past activity, something like
// keep track of connected clients
var clients = {}
app.on('open', (data, client)=>{
if (!clients[client.id]) clients[client.id] = {
active: false, // inactive by default ?
some_stat: 0 // keep track of client's activity one way or another
}
})
app.on('close', (data, client)=>{
// you might want to remove this part
// 'close' could be emitted upon browser reload
// and setting the 'active' flag manually in oscOutFilter should suffice
if (clients[client.id]) delete clients[client.id]
})
module.exports = {
oscOutFilter:function(data){
var {address, args, host, port, clientId} = data
// use outgoing message to determine if client is active ?
if (some_conditions_are_met) {
clients[clientId].active = true
}
if (!clients[clientId].active) return // silence inactive clients ?
return {address, args, host, port}
}
}