Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
jcdekoning #1
Member since Sep 2005 · 13 posts
Group memberships: Members
Show profile · Link to this post
Subject: Server and forwarding incoming messages
I am trying to create a XMPP Server. I use as base the example server. But i have some problems with the following things.

Incomming messages that are received by the server are send forward by using the same send message method as the client. Problem is that all the messages are returned to the client. Is this because the server only remembers the last connection?

When i connect two clients to the same server, the last connected client receives all messages even when the first connected client send a message.

Hope somebody can help me with this problem?
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi jdekoning,

each client (resource) that connects to your server has a permanent tcp-ip connection to your server. Your server needs a router that handels all this connections. You could use a Hashtable or smth else to store your connection by Jid. When one client sends a message to your server you have to check the the To Property of this message and search this connection in you router (hashtable). When the receiving contact is online send this message over the connection you found in the router. When the contact is offline store the message in a database and send it when this guy comes online the next time.

Alex
Avatar
alexan #3
Member since Aug 2006 · 7 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex

could you please give some example on how to store each client connection in hastable by jid and route message from 1 client to another client, thanks again....
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

i can't give you an example, but i try to explain it in detail.

Somewhere in your server you have a connection manager which is listening for client connections and accepts the connections. On Accept you know nothing (except of IP and Port) about the user which is trying to connect. You know the complete jid of the user after he is fully authenticated/binded. And this is where you can add the user with a reference to his socket connection to a collection.

So when you get a stanza which must be routed to another user you can lookup this user in your collection and decide what happens with this stanza. You will find of details about routing in the XMPP RFCs.
eg: messages routing is different than iq routing.

And keep in mind that a XMPP server normally handles more than only client connections. There are also component connections and s2s connections.

Alex
Avatar
alexan #5
Member since Aug 2006 · 7 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex

Thanks for your response,with your guide i finally success to route the message to the other client now, thanks  a lot :)

regards,

Alexander
This post was edited 2 times, last on 2006-08-10, 13:21 by alexan.
Avatar
Jabberer #6
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Hi Alexander,

look also in the XMPP-Core here:
Server Rules for Handling XML Stanzas

and also in the extensions for IM. because this rules of delivering iq and message stanzas are different.
Software Developer
AG-Software
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