FluuxIO / go-xmpp

Native Go XMPP library
https://www.process-one.net/
BSD 3-Clause "New" or "Revised" License
317 stars 63 forks source link

Add Server-To-Client handler #152

Open vduduh opened 4 years ago

vduduh commented 4 years ago

https://xmpp.org/extensions/xep-0199.html#s2c

p1bot commented 4 years ago

Hi @vduduh, many thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes.

p1bot commented 4 years ago

You did it @vduduh!

Thank you for signing the ProcessOne Contribution License Agreement.

We will have a look at your contribution!

remicorniere commented 4 years ago

Hello vduduh and thanks for contributing ! As pings described in XEP-0199 are IQ stanzas, and not nonzas, I'd rather have them processed by the router instead, in this function :

func (r *Router) route(s Sender, p stanza.Packet)

Also, as the spec that you linked says, the client must only respond if it supports the ping namespace. For now, there is no way for the client to say that it supports this feature because responding to IQ requests is not supported (also, we don't support it). We would need to implement that first.

If you'd like to have a go at it, that'd be great ! :)

vduduh commented 4 years ago

Hello @remicorniere ! Some servers force disconnection of clients if they do not respond to ping. That is why I implemented this functionality.

remicorniere commented 4 years ago

I understand. Thank you for suggesting this change.

Although for now I believe the code edits were not made in the right place (see my previous comment).
You can edit your patch to implement the suggested adjustments. Please let me know if you have any questions or need guidance ! :)
Also please refer to the guidelines: we are missing tests for your new feature. Could you please add some ?

For now I will link this PR to an issue reflecting your feature request.
Thanks !