xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.19k stars 373 forks source link

No API to remove an iq callee route #779

Closed wichert closed 4 years ago

wichert commented 4 years ago

We used to be able to unregister an iq callee route like so:

this.plugins['iq-callee'].setters.delete(xmlns)

This is no longer possible with the new middleware setup.

wichert commented 4 years ago

Some background here: we use that to only react to routes if certain React components are mounted.

sonnyp commented 4 years ago

Related https://github.com/xmppjs/xmpp.js/issues/643

XMPP being stateful, is is very unusual to dynamically remove handlers. Usually it's your handler that would decide whether to trigger actions/changes or not.

It is specially true for iq handlers as your application will change its contract "en route" and suddenly respond to them with a feature-not-implemented error and it does not play well with Service Discovery.

I believe it is a bad practice and would really advise against it, however I'm not totally against allowing it.

@wichert could you elaborate on the use case?

sonnyp commented 4 years ago

@wichert ping?

wichert commented 4 years ago

Sorry for the late response. Your argument makes a lot of sense. I've already refactored our code to always have the plugin running.