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

catch-all and missing event handler on client/server #5

Open
siddo420 opened this issue Dec 16, 2015 · 2 comments
Open

catch-all and missing event handler on client/server #5

siddo420 opened this issue Dec 16, 2015 · 2 comments

Comments

@siddo420
Copy link

  • Is it possible to define a catch-all event handler like '*' etc on client and server? This might be needed to send a response in case of missing event handlers.
  • Also, what happens if event handler does not exist? In my tests, nothing happens (no event handlers get called). Does it mean no memory is allocated/wasted etc in case of a huge number of such events?
  • On a slightly different topic, I am thinking of emitting events such that their response handlers could also be defined at the time of event emittance. For example,
primus.send({ emit: [...] }, timeout, success_cb, error_cb );

The .send method will do the heavy lifting of calling .write() and making sure timeout is not hit (error_cb will be called in that case). We need to make sure server side also deals with events appropriately and responds.

Has it been implemented already? Any tips on the most efficient way this could be achieved?

@lpinca
Copy link
Member

lpinca commented Dec 16, 2015

  1. No, our event emitter is an instance of eventemitter3 or Stream and wildcards are not supported there.
  2. Not much, a packet is sent from server to client or vice versa but if there isn't a listener on the receiving end, the emit method on that end returns false and nothing happens. You can't know if the other end has a registered listener for the event you are sending so the packet is sent in all cases.
  3. I'm not sure what you want to do, the feature seems similar to an "ack", primus-emitter supports "acks" but it doesn't take the timeout into account.

@siddo420
Copy link
Author

For 3: I am trying to use request-response pattern. And, in fact trying to somehow convert event-driven features to request-response pattern taking timeouts/disconnects etc into account.

I will look at primus-emitter and I hope primus-emitter is compatible with omega-supreme, primus-emit, substream, mirage, metroplex etc.

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

2 participants