views:

395

answers:

3

I'm building a live chat using JSJaC and ejabberd . It's all working except that all site visitors are given the account 'guest'. If two visitors try to livechat at the same time the responses get muddled or the first user is logged out.

I can randomly set the guest name but then I need to check whether that name is registered or auto-register and hope it hasn't been registered before. I tried assigning each login to a random resource name but this still merged the conversations.

In short i'm looking for the easiest way to allow multiple anonymous logins to start individual conversations with the livechat account. Even better (but optional) if the livechat could round-robin to a different user when the primary livechat account is in a chat.

The solution can be web-client or server based, I don't care since I control both (and ejabberd supports various modules).

BTW, when I try to auto-register a registered account the JSJaC simpleclient demo returns:

An error occured:
Code: 409
Type: cancel
Condition: conflict

I haven't established yet if this is something I can ignore or override with a custom client or server setup. I suppose I could just detect this error and try again without auto-register but I'd like to hear better/easier options.

A: 

Try enabling anonymous login mode on your ejabberd server? Then you don't have to register the client accounts, just pick any random username and password and ejabberd should accept them...

Stobor
thank you, I was not sure such a thing existed. Sounds like exactly what I'm after.
SpliFF
oddly enough it doesn't work, though I followed the instructions to the letter (I get 401 not-authorised errors). I'll ask over at serverfault or the ejabberd but this answer is still acceptable.
SpliFF
A: 

If you can't get ejabberd's anonymous mode working, you might try creating a GUID for each user's base name, and just registering the user on the fly. You'll want to have a periodic script that deletes old unused accounts from the database.

Joe Hildebrand
That's actually what I did in the end, though I used shorter names than a guid. It's too late to give you the answer though. I actually got anonymous mode working but it kept assigning GUID-like names instead of the one the user chose. The operators may be using PDAs/Iphones so I didn't want users like [email protected]/help clogging up chat window realestate.
SpliFF
A: 

We had a similar issue in a project - we wanted users to be able to login without requiring any account creation or clashes - auto-registration would not work for us because names could clash. In the end we chose anonymous login with SASL authentication in ejabberd - it allows anonymous login and dynamic account creation and I believe the accounts do not stay on the system (they are alive only whilst the connection is open), however from what I remember the server will generate a random ID for the user.

The GUID JID problem might be able to be solved with the use of Nicknames

Set up SASL

Ejabberd Support Page - SASL

Kinlan