2
votes

I have an ejabberd server and would like to write a web chat client for it. I've looked at things like Candy but they are a little over the top for what I want to do. I just want some basic features like instant messaging, group chat and presence.

I used the basic.html and basic.js example files from strophejs-1.0.2 as my base. I've managed to make a connection to my jabber server, join a conference, "try and send a message", leave the conference, and send an instant message to me. Most of that is working.

The issue I have is when the user logs in and joins a conference it tries to post a message to the group but fails.

<message xmlns="jabber:client" from="[email protected]" to="[email protected]/27311205821380711229538600" type="error">
<body>test2</body>
<error code="406" type="modify">
<not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></not-acceptable>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">It is not allowed to send private messages to the conference</text>
</error>
</message>

If I log into the conference as myself using Pidgin I can see the user in the conference. It has an icon next to it's name which has a dot and a number of circles around it. If I right-click on the user it says the user Status is Offline. This is strange as the user is online. If I look at the admin console for ejabberd I see the user is online. I have tried manually setting the presence like this before the user joins the conference:

connection.send($pres({type: "Available"}));

with this result:

<presence xmlns="jabber:client" from="[email protected]/27311205821380711229538600" to="[email protected]/27311205821380711229538600" type="Available"></presence>

Still the user has a status as Offline.

The IM it sends me when it's online is in red text in Pidgin. Normal messages look blue. I assume this is because it thinks the user is Offline.

I'm a little stuck. I wonder if someone can help me or point me in the right direction? I would firstly like to work out why this user looks Offline when it doesn't seem to be and fix it.

I've been looking at documentation about how to query the roster. I haven't had much success with this as well. I'm looking for a very basic example to show which users are online and their status with a call back to update if there are changes.

Can someone help me please?

2

2 Answers

5
votes

To set your initial presence:

connection.send($pres());

To check user's presence try using "probe":

var check = $pres({type: 'probe', to: '[email protected]'});        
connection.send(check);

If [email protected] is online it should return something like this:

<body xmlns="http://jabber.org/protocol/httpbind">
     <presence xmlns="jabber:client" from="[email protected]/4edf83f2" to="[email protected]/4edf83f2"></presence>
</body>
0
votes

+1 on the setting presence. You can use the ping plugin and do a ping-pong send-response to see if a user is online. Take a look at the roster plugin also. As for your issue between Pidgin and a web client, I have the same issues between ANY desktop client and my web interface showing available, however, I can chat between the 2.