Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Best way to route messages at the server level to recipients
Avatar
Hochman27 #1
Member since Sep 2015 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Want my own server to route message to recipient
Hi everyone,

I'm new to XMPP. I have just created a .Net server based on agsXMPP library. The server is able to receive messages from A but I am not sure how and when exactly I need to push those to the recipient B.

I know it should be done in real-time if B's presence is online or later if it's offline. However, I am not sure about the best practice here:
- should the thread running the first XmppServerConnection (handling sender A) put messages in a queue so another thread running another XmppServerConnection instance (handling recipient B) collects it from there? Is there a straighforward agsXMPP built-in way of doing that?
- or should I extend using Push Notifications?

N.B. my code resembles the one found here - below - and if you notice: line 140 just says "route the messages here" with no further explanations.
https://github.com/meebey/agsxmpp/blob/master/samples/VS20…

Finally, on https://www.ietf.org/rfc/rfc3921.txt it says:
   Exchanging messages is a basic use of XMPP and is brought about when
   a user generates a message stanza that is addressed to another
   entity.  As defined under Server Rules for Handling XML Stanzas
   (Section 11), the sender's server is responsible for delivering the
   message to the intended recipient (if the recipient is on the same
   server) or for routing the message to the recipient's server (if the
   recipient is on a different server).

So I assume there is no particular way to deliver but if someone could recommend something that worked well I'd be glad!

I appreciate any help :)

Thanks
This post was edited 2 times, last on 2015-09-13, 19:44 by Hochman27.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I suggest to take  a look at this server example:
https://gitlab.com/matrix-xmpp/samples/tree/master/csharp/…

for every client connected to your server you keep a ServerConnection object. If user A and B are online and user A sends a message to user B then you receive the message on one server connection and just send it on the other server connection. And of course you have to make your that the to and from addresses are correct.

Alex
Avatar
Hochman27 #3
Member since Sep 2015 · 4 posts
Group memberships: Members
Show profile · Link to this post
Thanks Alex. Totally makes sense. That was my plan B if there was no other way to push.

So I'll wait for B first to connect then I'll keep an instance of the connection.

Super quick reply btw..  Many thanks :)

N.B. am trying to set your reply as Best Answer or give thumb up but can't seem to find any of that. Plz tell me if am missing something obvious :)

Regards,
Hisham
This post was edited on 2015-09-13, 23:07 by Hochman27.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If B is offline you have to store the message in the offline storage and then deliver once B comes online and sends the initial presence.
Thats all defined in the XMPP RFCs.

Alex
Avatar
Hochman27 #5
Member since Sep 2015 · 4 posts
Group memberships: Members
Show profile · Link to this post
Sure - I already do that (store in DB for delayed delivery and wait for B to come online) - was just confused with regard to routing when B is online. Now it's clear! Thanks Alex.
Avatar
Hochman27 #6
Member since Sep 2015 · 4 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #4
Hi again Alex,

So I have implemented the server part where it should be using a global list of active connections. I've noticed, however, that the server connection is only added in ProcessBind(Iq iq) (in https://gitlab.com/matrix-xmpp/samples/blob/master/csharp/…).

Now my problem is: I can't get the client to trigger ProcessBind on the server. I have checked the client side but cannot find any example to send a Bind IQ (how/when/and why should we do that if login is equivalent to binding I believe).

I managed to do the same thing but differently so I add the server connection after authentication succeeds. Do I really have to wait for a Bind IQ?

Thanks in advance,
Hisham
This post was edited on 2015-09-20, 22:01 by Hochman27.
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
During Bind the resource gets assigned which is required in XMPP.
Your server should advertise the Bind feature, then the client automatically sends the Bind request.
Have you tried to run the server example I posted above?

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS