<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Unique Room Names for Multi-User Chat</title>
  <abstract>This specification defines an XMPP protocol extension for requesting a unique room ID from a multi-user chat service.</abstract>
  &LEGALNOTICE;
  <number>0307</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0045</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>muc-unique</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/muc-unique.xsd</url>
  </schemaloc>
  &stpeter;
  <revision>
    <version>0.1</version>
    <date>2011-11-10</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2011-09-26</date>
    <initials>psa</initials>
    <remark><p>First version, moved from XEP-0045.</p></remark>
  </revision>
</header>
<section1 topic='Introduction' anchor='intro'>
  <p>&xep0045; defines the protocol for groupchat in XMPP. In some situations, the room creator may want to request a unique room name before attempting to create the room (e.g., to avoid the possibility of a room conflict). Naturally, one way to do so is for the creator's client to generate a globally unique identifier, for example as defined in &rfc4122;. Another way is for the client to ask the MUC service for a unique room ID (which the service will thus reserve for that user).</p> 
</section1>

<section1 topic='Protocol' anchor='proto'>
  <p>The room creator requests a unique room name by sending an IQ-get to the service itself, containing an empty &lt;unique/&gt; element qualified by the 'http://jabber.org/protocol/muc#unique' namespace:</p>
  <example caption='Entity Requests Unique Room Name'><![CDATA[
<iq from='crone1@shakespeare.lit/desktop'
    id='unique1'
    to='chat.shakespeare.lit'
    type='get'>
  <unique xmlns='http://jabber.org/protocol/muc#unique'/>
</iq>
  ]]></example>
  <p>If the service supports this feature, it SHOULD return a unique room name as the XML character data of the &lt;unique/&gt; element (but not create the room):</p>
  <example caption='Service Returns Unique Room Name'><![CDATA[
<iq from='chat.shakespeare.lit'
    id='unique1'
    to='crone1@shakespeare.lit/desktop'
    type='result'>
  <unique xmlns='http://jabber.org/protocol/muc#unique'>
    6d9423a55f499b29ad20bf7b2bdea4f4b885ead1
  </unique>
</iq>
  ]]></example>
  <p>The service MAY refuse to return a unique room name to entities that are not entitled to create rooms, entities that have sent an excessive number of requests for unique room names, etc.</p>
  <p>The service MAY use any algorithm that ensures the creation of a room name that will be permanently unique in the context of the service (e.g., a cryptographic hash of the requesting JID, datetime, and random salt), or simply use a UUID as defined by <cite>RFC 4122</cite>.</p>
  <p>The room creator would then use the XML character data of the &lt;unique/&gt; element as the node identifier portion of the room JID it requests:</p>
  <example caption='Owner Creates Room With Unique Name'><![CDATA[
<presence 
    from='crone1@shakespeare.lit/desktop'
    to='6d9423a55f499b29ad20bf7b2bdea4f4b885ead1@chat.shakespeare.lit/firstwitch'>
  <x xmlns='http://jabber.org/protocol/muc'/>
</presence>
  ]]></example>
</section1>

<section1 topic='Determining Support' anchor='support'>
  <p>If a MUC service supports the protocol specified herein, it MUST advertise that fact by returning a feature of "http://jabber.org/protocol/muc#unique" in response to &xep0030; information requests &NSNOTE;.</p>
  <example caption="Service discovery information request"><![CDATA[
<iq from='crone1@shakespeare.lit/desktop'
    id='disco1'
    to='chat.shakespeare.lit'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
  ]]></example>
  <example caption="Service discovery information response"><![CDATA[
<iq from='chat.shakespeare.lit'
    id='disco1'
    to='crone1@shakespeare.lit/desktop'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    [...]
    <feature var='http://jabber.org/protocol/muc#unique'/>
    [...]
  </query>
</iq>
  ]]></example>
</section1>

<section1 topic='XML Schema' anchor='schema'>
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/muc#unique'
    xmlns='http://jabber.org/protocol/muc#unique'
    elementFormDefault='qualified'>

  <xs:element name='unique' type='xs:string'/>

</xs:schema>
  ]]></code>
</section1>

</xep>