Check if users are active

Dear all,

I'm building an interactive piece with the audience influencing the live electronics via OSC.
Right now I'm building a sort of autentication system:
I have a dropdown menu as suggested in this topic and in PureData I have a [route] object for routing the messages incoming from the various n-users.

The performance lasts 600 seconds, and I want only three audience memebers able to interact at a time, dividing the duration of the work equally between all the triplets of participants so that the Pd patch can receive the input from users x, y, z only for some seconds, and then switch to the next group.

To do this, I have the clientSync disabled, and I'm storing the inputs coming from the User dropdown in an array inside PureData as the users select options in it, so that it can eventually scan between the active users and do the trick.

The problem: when users select the wrong option in the dropdown, still Pd stores the value that they touched by mistake, and when the performance starts the patch will enable interactions also with those "phantom users" that have been created by accident. I'm trying to come up with a system for storing only the last values that have been selected from the autentication dropdown, but I'm really struggling
to do it.

I've also tried sending a [/GET /dropdown_id( message to be triggered as the performance begins, but I have no reaction at all from OSC.
Could you suggest a solution for this?

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}

    }

}

Thank you for the many rescues, @jean-emmanuel.
I think I will try to understand modules management and to follow you suggestion.
However, I would also like to understand how to use properly the /GET message.

I've tried, just for the sake of curiosity, the /SET and works just fine for simulating user interaction and setting-receiving values, and I thought the same could work for the /GET, by adding the /widget_id right next to it. Does it not work because of the async clients maybe?

The /GET command expects the first argument to be an ip:port string (Remote control - Open Stage Control)