Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
jogissa #1
Member since Feb 2008 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Get the status of a user by WebService
Hi all (and Alex, of course).

I am developing a Web service which returns the status of a determinate contact. As imputs, it has "user", "password" and target "contact".

What I have first done is to compare target contact with every sender of presence messages (in function onpresence), and if I have a coincidence, I return the Show or Type of the presence message. This is under a timeout of course. What happens is that I think this way is inefficient.

What I am wondering know is if there is a method just for asking server if a contact is online or not (no matters exact status or Show info). I am wondering that because from admin view in ejabberd I can see what users are online. If this method exists, my web service would be instantaneously.

Thanks in advance,

Best regards
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by jogissa:
I am developing a Web service which returns the status of a determinate contact. As imputs, it has "user", "password" and target "contact".

What I have first done is to compare target contact with every sender of presence messages (in function onpresence), and if I have a coincidence, I return the Show or Type of the presence message. This is under a timeout of course. What happens is that I think this way is inefficient.

does this mean that you open a new XmppConnection for each request to a status of a user?

Your webservice should be logged in as a XmppComponentConnection 24/7 and write all presence updates to a sql database table.
When you need the status of a special user then you have to do only a lookup of the status in the database which performs very well.

Quote by jogissa:
What I am wondering know is if there is a method just for asking server if a contact is online or not (no matters exact status or Show info). I am wondering that because from admin view in ejabberd I can see what users are online. If this method exists, my web service would be instantaneously.

no there isn't. The ejabberd web interface is build in in the ejabberd server, and has of course access to the all object and the memory. If yo have to show the status only of your own users which are on a ejabberd server the best solution is of course to hack a ejabberd erlang module.

Alex
Avatar
jogissa #3
Member since Feb 2008 · 6 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex
does this mean that you open a new XmppConnection for each request to a status of a user?
Yes, I am afraid so

Quote by Alex
Your webservice should be logged in as a XmppComponentConnection 24/7 and write all presence updates to a sql database table.
When you need the status of a special user then you have to do only a lookup of the status in the database which performs very well.
I see your point of view, and I will use it if the rate of searches is high, but if finally there is only one or two searches of status each time, for example, the easiest way I think is the way I've already done.

Quote by Alex
the best solution is of course to hack a ejabberd erlang module.
Yes, I agree (I wish I know how to do it  :-D )

Best regards
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by jogissa:
Quote by Alex
does this mean that you open a new XmppConnection for each request to a status of a user?
Yes, I am afraid so

You can speed up the login time and reduce the roundtrips when you don't retrieve the roster and agents (AutoRoster=false, AutoAgents=false) and connect without Tls (UseStartTls=false).
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