Background: I'm trying to build a survey app where users can add answers to the survey and have these answers pushed to other users (e.g. if the question is "What is your favorite programming language?" and I didn't include Haskell, the user can add "Haskell" as an answer, and it will show up on everyone's browser). I'm planning to use long polling to achieve this.
My conceptual approach: The approach that I've settled on is setting up something like an observer pattern (or maybe it is exactly like the observer pattern. I'm new to design patterns).
The steps would be something like this: The browser makes a request to /app/longpoll, which spins up a view which 1. uses time stamps to check if any changes have occurred, and if so returns those changes, or 2. registers itself with an event delegator and waits for a message. Then when a browser makes a request to /app/UpdateSurvey a view gets fired up which 1. updates the survey, and 2. informs the event delegator that the survey has been changed.
My question: Given that this is a sane approach to solving this problem, how do I implement it? It seems like I need a standing process to serve as the event delegator, but I'm really not sure what this looks like. How do I find this process to register with it? How do I register with it? How do I make this process exist in the first place? What happens if this process is busy delegating events when a answer gets added to the poll?
I recognize that this is asking for a long answer, and has probably been solved by other people, so article/book recommendations are also encouraged.