# HG changeset patch # User Waqas Hussain # Date 1253864368 -18000 # Node ID de165b5de25425d2dc888194b36e538fefaa2955 # Parent f67e4bfc62f10397ffa35bc630ba381efa5e15cc MUC: Added multi-session support to the room-exiting occupant use case. diff -r f67e4bfc62f1 -r de165b5de254 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Fri Sep 25 12:36:11 2009 +0500 +++ b/plugins/muc/muc.lib.lua Fri Sep 25 12:39:28 2009 +0500 @@ -215,10 +215,22 @@ elseif type == "unavailable" then -- unavailable if current_nick then log("debug", "%s leaving %s", current_nick, room); - local data = self._occupants[current_nick]; - data.role = 'none'; - self:broadcast_presence(pr); - self._occupants[current_nick] = nil; + local occupant = self._occupants[current_nick]; + local old_session = occupant.sessions[from]; + local new_jid = next(occupant.sessions); + if new_jid == from then new_jid = next(occupant.sessions, new_jid); end + if new_jid then + occupant.jid = new_jid; + occupant.sessions[from] = nil; + local pr = st.clone(occupant[new_jid]) + :tag("x", {xmlns='http://jabber.org/protocol/muc#user'}) + :tag("item", {affiliation=occupant.affiliation, role=occupant.role}); + self:broadcast_except_nick(pr, current_nick); + else + occupant.role = 'none'; + self:broadcast_presence(pr); + self._occupants[current_nick] = nil; + end self._jid_nick[from] = nil; end elseif not type then -- available