2

I need some advice on setting up an environment that is based on Django and XMPP.

My site has two parts.

Part A: users use an in-browser XMPP client, like Strophe.JS on a page that si served through Django.

Part B: Used by a different set of users to communicate with users who're communicating using the part A of the site. Users here will also use an in-browser XMPP client, like Strope.JS on a page that is server through Djano.

Since the communication happens in-browser, I'll not using a real XMPP stream but XMPP over BOSH. I've read that XMPP over BOSH is the de-facto way of transport XMPP messages over HTTP interfaces.

The solution for Part A is simple. A regular web-page with the Strophe.JS library thrown in. The difficult part for me seems to be figuring out how to handle the users of Part B. I need to relay XMPP messages between the Part A users and Part B users. The Part B users, need to able access information from the Django system for the user of Part A. I would need pretty good integration between XMPP and Django.

Could someone tell me how I would write a system like this? What tools would I use? Would a I use a stand alone XMPP server and integrate it to Django? If so, what? When a user on Part A initiates a chat session, it will show up on user of Part B of the site but which user will handle the chat request of the user will depend on some information retrieved from Django.

Thanks in advance everyone.

Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
  • 1
    You might want to look into [the technology behind Convore](http://www.eflorenzano.com/blog/post/technology-behind-convore/). – Daniel Roseman Jun 20 '11 at 08:50

1 Answers1

1

You'll definitely need stand alone Jabber/XMPP server (e.g. ejabberd). I'll make a wild guess that Part A users communicate within chat room A (MUC), and the same users in Part B communicate within chat room B. You need to write 3 scripts/daemons (I use perl and Net::Jabber (Net::XMPP can not join MUC)). They would be: scripta, scriptb, mediator.

  • script/daemon A will join the MUC room A, while mediator being part of it's roster. It will listen to all message stanzas but will react only to some (e.g. message stanza with body "SendToB MSG"). This message is sent by user that has joined chat room A. Then "RelayToB MSG" should be sent to mediator by scripta (From: scripta@jabberserver.dom, To: mediator@jabberserver.dom). The mediator will send the "RelayFromA MSG" to MUC B based on "RelayToB" part of the message stanza body. scriptb will receive "RelayFromA MSG" and will send "MSG" to chat room B.

  • script/daemon B (the same logic) with mediator@jabberserver.dom being in users roster.

  • mediator will not join any chat room. It will have scripta@jabberserver.dom and scriptb@jabberserver.dom in it's roster. It will only relay messages between the chat rooms.

I have already posted sample code here How to create a jabber/XMPP proxy/logging service?. The code will apply scripta/b. The code is rather long, and make sure you check InMessage and InPresence subs. Other stuff concerns my needs.

I hope I was clear enough. Don't hesitate to ask more questions.

EDIT:

  1. Create script using perl and Net::Jabber. The user that will login to XMPP server will be mediator@jabberserver.dom. Everyone will be able to send messages to him. The mediator will forward messages to the support person in format (From:user1 MSG). Support person will reply to mediator@jabberserver.dom with the message (Reply:user1 REPLY). The mediator will forward REPLY to user1.
  2. Check mod_shared_roster here http://www.ejabberd.im/shared-roster-all (example 4) and here http://www.process-one.net/docs/ejabberd/guide_en.html#htoc61.

I think that the 2-nd solution will require no additional coding apart from javascript/strophe code in your page.

Community
  • 1
  • 1
Gjorgji Tashkovski
  • 1,948
  • 1
  • 13
  • 14
  • Hi Gjorgji. I found something http://www.speeqe.com/. What do you think? The code is at https://github.com/thepug/speeqe/wiki. Does this look like a promising solution to you? Speeqe seems to create a multi-user chat room but what I need is a two person chat like FB, GTalk, etc. – Mridang Agarwalla Jun 30 '11 at 07:18
  • Then my wild guess seems incorrect :). First, can you please explain what do you mean Part A, and Part B of your site in more details. – Gjorgji Tashkovski Jun 30 '11 at 07:36
  • To simply stuff: I need a to implement a live-chat system. A user on the site can start a chat and the support people behind the site can assist the user. The messaging needs to be based on XMPP. Does this clarify it? A user on the site is only chatting with one person at a time but the support personnel is handling multiple chats. – Mridang Agarwalla Jun 30 '11 at 07:40
  • There are two solutions that come to my mind which I''ll elaborate in my edited answer. – Gjorgji Tashkovski Jun 30 '11 at 08:19