Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event listener on server on client connect #73

Open
mageeagle opened this issue Nov 6, 2023 · 0 comments
Open

Event listener on server on client connect #73

mageeagle opened this issue Nov 6, 2023 · 0 comments

Comments

@mageeagle
Copy link

Hi! Thanks for creating this awesome library!

I am trying to have a bunch of OSC messages saved on the node server using the Bridge Plugin, so they could be sent to the browser client when they connect to the server. But I can't seem to find an event listener that listens to a new connection on the server and sending a message only to the new client.

Right now I'm using a workaround, which the client sends a message to the server on connection, which then in turn responds with the saved OSC messages. Though this would broadcast the message to other connected clients as well and might cause issues.

Client

osc.on('open', () => {
  const oscMsg = new OSC.Message('/connected', true)
  osc.send(oscMsg)
})

Server

const savedMessage = 123
osc.on(/'connected', () => {
  const oscMsg = new OSC.Message('/example', savedMessage)
  osc.send(oscMsg) // This broadcasts the osc message to all connected clients instead of only the new client
})

Any ideas on how to only respond to a new client?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant