Replying here because this discussion seems more on-topic with the original question.
To avoid using the
id
here's what could work:
- create an empty session with this in the root's
onCreate
script:send('127.0.0.1:10000', '/session', globals.env.session)
this session will act like a hub and send the "session" parameter found in the url (like you did with the id)
- set the server's
load
option to that hub session file- in the custom module, catch the outgoing
/session
message and use it to make the client load the session you want.
I have done this and it mostly works, thanks!
My custom module looks like this:
const default_session = 'default.json'
const sessions = {
'1': 'one.json', // for client loading "http://server:port?session=1"
'2': 'two.json', // for client loading "http://server:port?session=2"
'3': 'three.json' // for client loading "http://server:port?session=3"
}
module.exports = {
oscOutFilter:function(data){
if (data.address === '/session') {
// don't actually send a message, load the desired session file
receive('/SESSION/OPEN',
(sessions[data.args[0].value] || default_session),
{clientId: data.clientId}
)
}
else {
return data
}
}
}
However this will NOT actually redirect from the "hub" session file to the target session file unless I add a small delay on create. This feels a little fishy too me as I suspect all I am doing is trying to fix some race condition with a delay. Eventually I'll hit some time when I lose the race and my session doesn't load. It also doesn't look very "professional" because my interface flashes when I reload due to the delay. Any ideas? For reference, this is what I ended up using for the onCreate script in the hub.json file:
setTimeout(() => {
send('127.0.0.1:10000', '/session', globals.env.session)
}, 100) // delay 100ms
cheers,
Rob