5

When a user joins an ejabberd MUC, the server will send a full room roster and chat history to the user.

In my web based client I need to persist the room over page reloads. My problem is that I loose al the initial information when the page is unloaded.

ATM I'm working around this by serialising the roster and room history to json and storing it in a cookie. However, this is a really bad idea (tm) as I can very quickly exceed the 4k general cookie limit for rooms with alot of users.

So the question: How can I re-request the information the server sends a user on join, without actually rejoining a MUC?

One approach for rosters would be to send a query iq with a namespace of "http://jabber.org/protocol/disco#items" but this is incomplete as it doesn't provide presence information or any extended info (such as real jids for non-anonymous rooms)

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
Ollie Edwards
  • 14,042
  • 7
  • 28
  • 36

3 Answers3

1

On page unload you need send "presence unavailable"

On page load (rejoin to room) send "presence available" plus "history" request. For example,

<history maxstanzas=20 />

Reference to XEP-0045 scheme

1

Hmm. I don't have a solution for Roster, but on the history one, have you tried this?

<iq to="room@conference.xmpp.org" type="get">
  <history xmlns="http://www.jabber.com/protocol/muc#history" start="1970-01-01T00:00:00Z" direction="forward" count="100" />
</iq>
DashK
  • 2,640
  • 1
  • 22
  • 28
0

Try leaving the muc room when page unload and re-send presence to the muc when page re-load.

pincopallo
  • 643
  • 5
  • 2
  • "without actually rejoining a MUC" was the important bit you missed there. If i leave the room on page reload then every user will be notified as such, then notified again when the user rejoins. This somewhat defeats the point of reattaching to the same session. – Ollie Edwards Dec 09 '10 at 17:29
  • Yes... you're right! That was the quick way to achieve what you want. Probably the only clean solution is to modify ejabberd in order to send history and roster again after each user presence on a Muc. Enjoy! – pincopallo Jan 28 '11 at 13:49