-
Notifications
You must be signed in to change notification settings - Fork 378
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
Adopt junction middleware #439
Comments
Crazy I've never heard of junction before. We're already using @smokku perfect timing, I was looking today at our current plugin API and how to tweak it to for server usage as well so I started hacking a connect like API. Wether we port junction or adopt a similar API, it is gonna require some work though and I'd like to release 1.0 ASAP as more and more people are getting confused about the rewrite/rename and the current state. So 👍, let's go back to this after 1.0 release. Meanwhile, I'm wondering how well this API plays client side, any thoughts? |
Sure. 1.0 shouldn't wait for it. I like junction very much. |
In my server implementation I have three separate Junction chains handling packets incoming to clients, packets incoming to server instance and outgoing packets sent by clients. Each have very different characteristics of how it needs to process stanzas, yet some elements ale common. This use case is enabled by clear separation of junction stack and node-xmpp incoming stanza handling. You can hook Junction to any emitter emitting stanzas. Or even inject stanzas manually (with some pre-processing). |
BTW, If we decide to port Junction I could do it. I already forked it and know my way around it. It would be nice to have green light from @jaredhanson though. :-) |
we now have a junction inspired middleware API |
There is one, crucial thing missing in the current middleware implementation compared tu Junction - automatic error handling. Junction handler can throw or pass an Error instead of packet, and this will get converted to an error response (if the processed stanza is of type requiring/supporting response). See errorHandler.js This makes error handling&responding close to trivial. If you detect a problem with the processed stanza, just instanitate StanzaError and reject a promie, or just Also, when there is an error in your code, the |
@sonnyp mentioned in some comment, that we would like to have a stanza routing middleware, to handle application-lever stanza routing.
What about adopting https://github.com/jaredhanson/junction ?
It has an extensive set of plugins, both bundled and stand-alone. It has a nice, express.js inspired stanza handling model.
I use it in both my XMPP client application, and also in XMPP server implementation and it works great.
I already ported it for new xmpp.js changes: https://github.com/smokku/junction
@jaredhanson what do you think? Your repo looks dormant. It would be a shame to let this nice code slip to oblivion.
The text was updated successfully, but these errors were encountered: