<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<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>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0307</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <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>
  
  <author>
    <firstname>Peter</firstname>
    <surname>Saint-Andre</surname>
    <email>stpeter@stpeter.im</email>
    <jid>stpeter@jabber.org</jid>
    <uri>https://stpeter.im/</uri>
  </author>

  <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><span class="ref"><link url="https://xmpp.org/extensions/xep-0045.html">Multi-User Chat (XEP-0045)</link></span> <note>XEP-0045: Multi-User Chat &lt;<link url="https://xmpp.org/extensions/xep-0045.html">https://xmpp.org/extensions/xep-0045.html</link>&gt;.</note> 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 <span class="ref"><link url="http://tools.ietf.org/html/rfc4122">RFC 4122</link></span> <note>RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace &lt;<link url="http://tools.ietf.org/html/rfc4122">http://tools.ietf.org/html/rfc4122</link>&gt;.</note>. 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 <span class="ref"><link url="http://tools.ietf.org/html/rfc4122">RFC 4122</link></span> <note>RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace &lt;<link url="http://tools.ietf.org/html/rfc4122">http://tools.ietf.org/html/rfc4122</link>&gt;.</note>.</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 <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note> information requests (see <link url="#ns">Protocol Namespaces</link> regarding issuance of one or more permanent namespaces).</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>
