0

i've set up a live chat using ejabberd. It's working pretty well but I'd like to be able to round-robin chat sessions to different operators depending on who is already in a chat and who is free to talk. To implement this I need some way to update a users presence based on wether they are currently in a private chat. I'm currently using mod_shared_roster to advertise presence but it only reports wether a user is available.

This really needs to be done server side because I will need to rely on different IM clients depending on the operators' system.

SpliFF
  • 394
  • 2
  • 7
  • 24

2 Answers2

0

I've found a workaround. Since the livechat system uses jsjac (javascript interface to xmpp) I can craft my own presence packets. When a client connects to an operator I set the clients' presence to 'chat' and status to 'talking to <operator jid>'.

When a new client connects I can query the status of all other clients to see who they are chatting to and choose the operator with the least active chats.

If anyone knows a better/easier way I'm happy to hear it.

SpliFF
  • 394
  • 2
  • 7
  • 24
0

You may consider connecting all operator sessions under one account and different resources. Ex. help@example.com/Operator1 help@example.com/Operator2 help@example.com/Operator3 All with priority 1.

When an operator is in chat with user, send presence with priority -1. This removes the resource from a resource pool to contact when user sends message to 'help@example.com'. When operator finishes chatting with user - send presence with priority 1.

An added feature of this model is that you have only one Jabber ID to communiate to your users - help@example.com

smokku
  • 216
  • 1
  • 3