Intercept? new messages between server and clients

Hi community!

Currently I need to do a meteor app which I need to send events from the server to a client, i.e.: show some new information when another process sends me a message.

The problem is the reactivity… I need to do some action (play a sound) when the other process sends me a new message.

How can I do this? There is any way to know if I’ve recieved a new message? Something like a hook or another way to send the message except with collections?

Thank you all!!!

Hi @nullpo,

The great thing about Meteor is the fact that there are 100’s of options out there to do exactly what you are trying to do.
I will start by trying to narrow down an option that may or may not work for you , but I’ll let you decide.

One option that comes to mind is possibly using tracker autorun. An even simpler option could be utilizing sessions. You could set a session variable called “pendingMessage”. When the server sends it’s response have it also set the session to true or some known value. Listen for the change in the session and play the sound when it’s value changes. On the actual event, when the item is viewed or read, you can clear the session back to either an empty string or a “false”.

I’m not sure if this will help but it’s an idea,
Let me know your thoughts.


1 Like

Thank you for your answer rwatts. After some time, I think that your solution was the best idea for now… We do the app using your idea and we have no problems, so thank you!!! :smiley:

@nullpo I am very pleased to hear that this method has worked for you. I
wish you much success with future development.