Capture more than one OSC return message - Interacting with nsm

Hi there,
I’m trying to build a basic nsm (non session manager) with Open Stage Control.
for instance I’d like to list the available session. nsm accept this command (API is here) :
/nsm/server/list
in response, nsm send multipl message :
/reply /nsm/server/list <name of session #1>
/reply /nsm/server/list <name of session #2>
...
I see how I can send a message and recieve and answer, but how can I recieve multiple answers in order to put them on a list ?

Processing incoming messages should be done with a custom module, you should be able to implement what you need here. Here is a barebone example:

// initialize list
var sessionList = []

module.exports = {

    oscOutFilter: function(data) {

        var {host, port, address, args} = data

        if (address === '/nsm/server/list') {

            // reset list when OSC client sends '/nsm/server/list
            sessionList = []
        
        }

        return {host, port, address, args}
    
    },

    oscInFilter: function(data) {

        var {host, port, address, args} = data


        if (address === '/reply') {

            if (args[0].value === '/nsm/server/list') {
                // feed list when osc receives /reply /nsm/server/list
                sessionList.push(args[1].value)

                // then, do something with that list
                // maybe feed an osc listener (OSC{} syntax) with receive() 
                // or edit the client interface with receive('/EDIT', ...)
                // or query something else from NSM with send()
            
            }

        
        }

        return {host, port, address, args}
    }
    
}
1 Like