Difference between revisions of "XEP-Remarks/XEP-0045: Multi-User Chat"

From XMPP WIKI
Jump to: navigation, search
(MUC double join)
(Am I still there?)
Line 36: Line 36:
 
The "most viable" workaround is:
 
The "most viable" workaround is:
  
Periodically do:
+
# set a (short, like maybe 15mins, or periodic) timeout after the last stanza received from a MUC
* send a XEP-0199 ping IQ to your participant JID (it might get reflected to your client or to another one)
+
# on timeout: send a ping IQ to your own participant JID
* set a timer
+
# (maybe) respond to the reflected ping IQ, depending whether you are the "most active" MSN and on the phase of the moon
* if you receive a ping, respond to it
+
# if the ping IQ is responded to with iq-result, service-unavailable (official RFC response for a feature not implemented) or  feature-not-implemented (incorrect but found in the wild response for feature not implemented): phew, we are still joined, we are done
* once you receive the ping response, you know you are still joined - stop the timer
+
# if the ping IQ is responded to with anything else: we lost the connection to the MUC
* if the timer fires, you are probably not joined any more
+
#* send presence-unavailable
** send presence unavailable
+
#* rejoin
** send join presence
+
# if the ping IQ times out, one of your clients probably lost the connection to the MUC, just to be sure we need to:
 +
#* send presence-unavailable
 +
#* rejoin
  
 
= MUC double join =
 
= MUC double join =

Revision as of 19:44, 11 April 2018

Stable Message IDs

As of 2018, server implementations are required to keep the message ID when reflecting client messages. This can be determined by the presence of the 'http://jabber.org/protocol/muc#stable_id' feature on the MUC JID or MUC domain.

Ambiguities

http://mail.jabber.org/pipermail/standards/2014-April/028805.html

Introduces 'ofrom' Extended Stanza Addressing (XEP-33) type

in http://xmpp.org/extensions/xep-0045.html#enter-history, which is not found in XEP-33 (nor XEP-33s schema).

Matching Your Reflected Message

So you sent a message to a MUC and want to immediately display it as "on the way" (good UX). Some time later (usually within some seconds) you receive a message from the MUC which might or might not be your sent message.

Find out if a relfection is your actual message, in six easy steps! The message is your reflection if:

  1. you recently sent a message to the MUC, AND
  2. the received message is from your participant JID, AND
    1. the XEP-0359 origin ID matches (probably not a transport) OR
    2. the message ID matches (a nice MUC, but not required by the XEP) OR
    3. the message body matches (not conclusive, some MUCs auto-pastebin) OR
    4. the received message is the first line of the sent message (transports like IRC split multi-line messages into one-liners) OR
    5. the sent message is very long (>400 bytes) and the received message is a prefix of it (IRC transpors split very long one-liners too!)

(this mechanism doesn't cover MUCs which don't reflect the message ID and do autopastebin. Screw them!)

Am I still there?

Current MUC / server implementations do not send offline-presence packets to participants on service restart. Therefore, a client will think it is still joined to a MUC indefinitely, only seeing silence.

There is no portable/reliable mechanism to check if the client is still joined, and no clean way to re-sync the state if it is not joined. Sending a "silent" message or presence update to the MUC will lead to O(N²) complexity (if every client does so), killing all our batteries.

The "most viable" workaround is:

  1. set a (short, like maybe 15mins, or periodic) timeout after the last stanza received from a MUC
  2. on timeout: send a ping IQ to your own participant JID
  3. (maybe) respond to the reflected ping IQ, depending whether you are the "most active" MSN and on the phase of the moon
  4. if the ping IQ is responded to with iq-result, service-unavailable (official RFC response for a feature not implemented) or feature-not-implemented (incorrect but found in the wild response for feature not implemented): phew, we are still joined, we are done
  5. if the ping IQ is responded to with anything else: we lost the connection to the MUC
    • send presence-unavailable
    • rejoin
  6. if the ping IQ times out, one of your clients probably lost the connection to the MUC, just to be sure we need to:
    • send presence-unavailable
    • rejoin

MUC double join

This has been fixed in revision 1.29 of XEP-0045:

It's not specified what should happen if an entity sends an initial presence when it's already joined. Server implementations should behave towards the joining entity like it successfully joined. That means, if a presence update containing an <x> element is received from a participant, the server should send back the full presence list, the requested amount of history and the room subject.

MUC PM messages are not distinguishable from other MUC messages

http://mail.jabber.org/pipermail/standards/2015-May/029819.html