designing a one-to-one chat system in a dating website

Hi all,

I am a previous Wildfire/Openfire user, and I have recently decided to migrate to ejabberd. The reason is simple: I have a dating website in development since a long time and I couldn't achieve any chat solution with Openfire. Their product is quite simple to use but the lack of documentation made me decide to quit it and move to ejabberd, especially when I read that Facebook and Meetic use it.
I have to admit ejabberd is also very simple to install, but when it comes to configuration and modules installation, it becomes a bit more hardy. Anyway, I am not at this point right now, I can already be happy with jsjac that is now working with ejabberd while it never worked with Openfire! A big step for me, because I can already think of a javascript based solution for my chat client rather than a flash one.

Now my question is actually about the best design, keeping in mind the very basic dating flow :
-X makes a search
-X sends a friend request to Y
-Y accepts the request
-Since then, X can view Y photos, details... but can also send a chat request (same for Y)
-Y accepts the chat request and the session is now open between them.

Classic? isn't it...

But when it comes to coding it things become more complex. There must be a synchro between "PHP chat requests" and the real "jabber roster subscriptions" and here is where I fail. I didn't find any solution to manage this. Is there a "classic" way to do this? does anyone have any tip or trick?
Does anyone have an idea how to create a facebook-like chat client ? I read about Comet Programming & Long Polling but how to apply this on a chat client?

Any comment or tip is welcome!
Thanks in advance!

Some Jabber details. How to add contacts with ejabberd commands

1. -X makes a search
2. -X sends a friend request to Y
3. -Y accepts the request

Now your webapp must tell ejabberd to add X as contact of Y, and Y as contact of X. If you have the webapp and ejabberd in the same machine, this can be done with shell calls. Other solutions are to send XML-RPC calls, or REST HTTP calls. See later.

4. -Since then, X can view Y photos, details... but can also send a chat request (same for Y)

By default in Jabber/XMPP/ejabberd, you can chat with anybody, even if he is not in your roster. You don't need his pre-approval. Of course, if your users only use a client written by you, you can implement in your client this limitation: "you only can send messages to approved contacts".

5. -Y accepts the chat request and the session is now open between them.

In Jabber/XMPP/ejabberd there isn't conversation pre-approval. I consider normal that, when you accept/approve a new contact, you allow him to chat with you anytime.

Explanation of "this can be done with shell calls" when using ejabberd 2.1.0-beta2:
1. Install ejabberd
2. Download mod_admin_extra from ejabberd-modules SVN, compile, install and enable in config.
3. Start ejabberd
4. Create users x@localhost and y@localhost
For example:

$ ejabberdctl register x localhost mypassxx
User x@localhost succesfully registered

$ ejabberdctl register y localhost mypassyy
User y@localhost succesfully registered

5. Add both users as contacts. For example:

$ ejabberdctl add_rosteritem x localhost y localhost \"Mr. Y\" Friends both

$ ejabberdctl add_rosteritem y localhost x localhost \"Dr. X\" \"Friends from school\" both

6. Enter the ejabberd WebAdmin to verify the rosters were correctly updated.

If you prefer to use XML-RPC calls, install ejabberd_xmlrpc. If you prefer REST HTTP calls, install mod_rest.

Thanks for answering

Thanks for answering badlop.

I didn't install the 2.1 yet, I have the previous version, so I can't use those shell commands right now.
So I will have a look at the REST and XML RPC methods.

For ejabberd 2.0.* you can

For ejabberd 2.0.* you can use shell commands thanks to mod_ctlextra; or XML-RPC calls with mod_xmlrpc. You can't use mod_rest in ejabberd 2.0.* to execute commands.

Hi, I tried the shell

Hi,

I tried the shell commands and they work great except when I exec them from php, this is certainly due to some privileges.
I will try the XML_RPC method in order to anticipate the execution of ejabberd on a different server.

actually I meant mod_xmlrpc

actually I meant mod_xmlrpc (not ejabberd_xmlrpc) :)

Ok, I tried to install the

Ok, I tried to install the ejabberd_xmlrpc module, but it doesn't seem to be loaded, I don't see it listed in the modules page.
Then I read (http://www.ejabberd.im/ejabberd_xmlrpc) it requires "XML-RPC-Erlang 1.13 with IP, Ruby and Xmerl 1.x patches".
If I get the compiled version of those patches, do I have to place the correspondant beam files in the ebin folder with the other modules? Then which ones of those beams have to be added in the ejabberd config file/modules section?

Sorry all this is new to me, I have absolutely no idea about it

got mod_xmlrpc working

got mod_xmlrpc working ;)
thanks badlop.

Syndicate content