<remark><p>Clarified business rules regarding generation of notifications; added reference to XEP-0155; rewrote introduction; moved previous introductory text to section on superseding XEP-0022.</p></remark>
<remark><p>Added optional <initial/> state; added business rule on repetition of notifications; added implementation note.</p></remark>
</revision>
<revision>
<version>0.9</version>
<date>2004-10-28</date>
<initials>psa</initials>
<remark><p>Made <inactive/> state definition consistent with <paused/> per list discussion; made slight adjustments to wording throughout.</p></remark>
</revision>
<revision>
<version>0.8</version>
<date>2004-10-28</date>
<initials>psa</initials>
<remark><p>Further clarified state definitions and adjusted suggested event timing.</p></remark>
</revision>
<revision>
<version>0.7</version>
<date>2004-10-27</date>
<initials>psa</initials>
<remark><p>Clarified the meaning of the <gone/> state; adjusted suggested timing for events.</p></remark>
</revision>
<revision>
<version>0.6</version>
<date>2004-02-19</date>
<initials>psa</initials>
<remark><p>Added <paused/> state; defined the chat states; clarified the state chart; simplified the business rules.</p></remark>
</revision>
<revision>
<version>0.5</version>
<date>2003-09-18</date>
<initials>psa</initials>
<remark><p>Clarified that 'type' must be "chat" or "groupchat" for chat state notification messages.</p></remark>
</revision>
<revision>
<version>0.4</version>
<date>2003-05-22</date>
<initials>psa</initials>
<remark><p>Made Thread IDs optional; made <inactive/> and <gone/> states optional if Thread IDs are not used; removed requirement for explicit service discovery in favor of implicit discovery.</p></remark>
</revision>
<revision>
<version>0.3</version>
<date>2003-05-20</date>
<initials>psa</initials>
<remark><p>Clarified terminology; added support for groupchat; added several implementation notes.</p></remark>
<p>Many instant messaging systems include notifications about the state of one's conversation partner in a one-to-one chat (or, sometimes, in a many-to-many chat). Usually these are limited to notification that one's partner is currently typing -- e.g., the Composing event in <cite>XEP-0022</cite> (see &xep0022;). However, a composing event is essentially information about a person's participation in or involvement with the chat "session" and therefore is really a session-level state rather than a per-message event -- e.g., the Delivered and Displayed events in <cite>XEP-0022</cite>. While the composing event is interesting, the concept of a session-level state can be extended to answer a variety of questions about the participation of a person in a real-time chat conversation, such as:</p>
<p>To answer such questions, this document supplements the traditional composing state by defining four additional chat states (paused, active, inactive, gone), for a total of five states that (it is hoped) together fully describe the possible states of a person's participation in or involvement with a chat conversation. <note>These states do not necessarily refer to the state of the client interface and certainly not to the disposition of a particular message. However, the user's involvement with the system, device, chat interface, or input interface can provide important clues regarding the user's involvement with the chat session, which should be used by the client in determining when to generate chat state notifications.</note></p>
<p>In essence, chat state notifications can be thought of as a form of chat-specific presence. For example, consider what might happen if a user "loses" a chat window on his desktop; the user might still be interacting with his messaging client (thus never automatically changing his basic presence to "away"), but the user's state with regard to the chat session might change progressively from active to inactive to gone. This information would help the user's conversation partner understand why she has not received a response to her messages in the chat session.</p>
<p>Chat state notifications can appear in two kinds of &MESSAGE; stanzas:</p>
<ul>
<li>A "content message" -- that is, a message stanza that contains standard messaging content such as the <body/>, <subject/>, and <thread/> child elements defined in &xmppim; and/or any other properly-namespaced child element(s).</li>
<li>A "standalone notification" -- that is, a message stanza that does not contain standard messaging content but instead is intended to specify only the chat state since it contains only a child element qualified by the "http://jabber.org/protocol/chatstates" namespace (or possibly also the XMPP <thread/> element; see the <linkurl='#bizrules-threads'>Threads</link> section below).</li>
</ul>
<p>The five chat states specified in this document are described below. The suggested triggers and state changes are simply that: suggestions. It is up to the implementation to determine when to generate chat state notifications and which notifications to generate.</p>
<tablecaption='Chat States'>
<tr>
<th>State</th>
<th>Definition</th>
<th>Suggested Triggers</th>
<th>Suggested State Changes</th>
</tr>
<tr>
<td><active/></td>
<td>User is actively participating in the chat session.</td>
<td>User accepts an initial content message, sends a content message, gives focus to the chat interface, or is otherwise paying attention to the conversation.</td>
<td><inactive/>, <composing/></td>
</tr>
<tr>
<td><composing/></td>
<td>User is composing a message.</td>
<td>User is interacting with a message input interface specific to this chat session (e.g., by typing in the input area of a chat window).</td>
<td><active/>, <paused/></td>
</tr>
<tr>
<td><paused/></td>
<td>User had been composing but now has stopped.</td>
<td>User was composing but has not interacted with the message input interface for a short period of time (e.g., 5 seconds). <note>An implementation may also "guess" that composing has been paused based on a change in the user's interaction with the message input interface, e.g. if the user switches window or application focus.</note></td>
<td>User has not been actively participating in the chat session.</td>
<td>User has not interacted with the chat interface for an intermediate period of time (e.g., 30 seconds).</td>
<td><active/>, <gone/></td>
</tr>
<tr>
<td><gone/></td>
<td>User has effectively ended their participation in the chat session.</td>
<td>User has not interacted with the chat interface, system, or device for a relatively long period of time (e.g., 2 minutes), or has terminated the chat interface (e.g., by closing the chat window).</td>
<td><active/></td>
</tr>
</table>
</section1>
<section1topic='State Chart'anchor='statechart'>
<p>The following figure attempts to capture the possible state transitions in visual form.</p>
<code><![CDATA[
o (start)
|
|
INACTIVE <--> ACTIVE <--> COMPOSING
| ^ |
| | |
+ <------PAUSED<-----> +
]]></code>
<p>Note: All four of the states shown may transition to the GONE state.</p>
<p>If an entity supports the Chat State Notifications protocol, it MUST advertise that fact in its responses to &xep0030; information ("diso#info") requests by returning a feature of "http://jabber.org/protocol/chatstates":</p>
<p>In addition, support for the Chat States Notification protocol can be determined through the dynamic profile of Service Discovery defined in &xep0115;.</p>
<p>Before generating chat state notifications, a User SHOULD explicitly discover whether the Contact supports the protocol defined herein (as described in the <linkurl='#disco'>Discovering Support</link> section of this document) or explicitly negotiate the use of chat state notifications with the Contact (via &xep0155;).</p>
<p>In the absence of explicit discovery or negotiation, the User MAY implicitly request and discover the use of chat state notifications in a one-to-one chat session by adhering to the following business rules:</p>
<olstart='1'>
<li>If the User desires chat state notifications, the initial content message sent to the Contact MUST contain a chat state notification extension, which SHOULD be <active/>.</li>
<li>Until receiving a reply to the initial content message (or a standalone notification) from the Contact, the User MUST NOT send subsequent chat state notifications to the Contact.</li>
<li>If the Contact replies to the initial content message but does not include a chat state notification extension, the User MUST NOT send subsequent chat state notifications to the Contact.</li>
<li>If the Contact replies to the initial content message and includes an <active/> notification (or sends a standalone notification to the User), the User and Contact SHOULD send subsequent notifications for supported chat states (as specified in the next subsection) by including an <active/> notification in each content message and sending standalone notifications for the chat states they support (at a minimum, the <composing/> state).</li>
<p>The foregoing rules imply that the sending of chat state notifications is bidirectional (i.e., both User and Contact will either send or not send chat state notifications) rather than unidirectional (i.e., one of the conversation partners will send chat state notifications but the other will not); this is by design.</p>
<p>Note: Support for only <active/> and <composing/> is functionally equivalent to supporting the Composing event from <cite>XEP-0022</cite>.</p>
<p>Even if the user types continuously for a long time (e.g., while composing a lengthy reply), the client MUST NOT send more than one standalone <composing/> notification in a row. More generally, a client MUST NOT send a second instance of any given standalone notification (i.e., a standalone notification MUST be followed by a different state, not repetition of the same state). However, every content message SHOULD contain an <active/> notification.</p>
</section2>
<section2topic='Context of Usage'anchor='bizrules-context'>
<ol>
<li>This protocol MUST NOT be used with stanzas other than &MESSAGE;.</li>
<li>This protocol SHOULD NOT be used with message types other than "chat" or "groupchat".</li>
<li>The 'type' attribute for content messages and standalone notifications SHOULD be set to a value of "chat" (for one-to-one sessions) or "groupchat" (for many-to-many sessions).</li>
<li>A chat session MAY span multiple user sessions (i.e., chat state is orthogonal to the availability and presence of one's conversation partner), although this is unlikely given the suggested timing of event triggers.</li>
</ol>
</section2>
<section2topic='Use in Groupchat'anchor='bizrules-groupchat'>
<li>A client MAY send chat state notifications even if not all room occupants do so.</li>
<li>A client SHOULD NOT generate <gone/> notifications.</li>
<li>A client SHOULD ignore <gone/> notifications received from other room occupants.</li>
</ol>
<p>Note: Use of chat state notifications in the context of groupchat may result in multicasting of such notifications. Forewarned is forearmed.</p>
</section2>
<section2topic='Syntax of Notifications'anchor='bizrules-syntax'>
<ol>
<li>A message stanza MUST NOT contain more than one child element qualified by the 'http://jabber.org/protocol/chatstates' namespace.</li>
<li>A message stanza that contains standard messaging content -- i.e., the <body/>, <subject/>, and <thread/> child elements defined in &xmppim; and/or any other properly-namespaced child element(s) -- SHOULD NOT contain a chat state notification extension other than <active/>.</li>
<li>A message stanza that does not contain standard messaging content and is intended to specify only the chat state MUST NOT contain any child elements other than the chat state notification extension, which SHOULD be a state other than <active/>; however, if threads are used (see below) then the standalone notification MUST also contain the <thread/> element.</li>
<p>While chat state notifications provide a mechanism for managing chat threads (i.e., the <thread/> element), support for threads is OPTIONAL. However, if all of the clients participating in a chat both support and use threads, the following additional business rules apply:</p>
<ol>
<li>Clients MUST copy back Thread IDs (i.e., the value of the <thread/> element) in any replies.</li>
<li>When a client terminates a one-to-one chat session (e.g., when a user closes the chat session interface), it MUST generate a <gone/> event.</li>
<li>Upon receiving a <gone/> event, a client MUST NOT re-use the same Thread ID and MUST generate a new Thread ID for any subsequent chat messages sent to the conversation partner.</li>
</ol>
</section2>
<section2topic='Server Handling of Notifications'anchor='bizrules-notify'>
<p>Servers in constrained network environments (e.g., serving small-footprint clients via &xep0025; or &xep0124;) and services that rebroadcast message stanzas (e.g., Multi-User Chat services) MAY process standalone notifications differently from other messages. In particular, a server or service MAY refuse to deliver standalone notifications to its users, and SHOULD NOT store them offline. In contrast to <cite>XEP-0022</cite>, chat state notifications are completely the responsibility of the client, and MUST NOT be generated by a server or service.</p>
<p>At this point Juliet's client knows that Romeo's client supports chat state notifications. Thus she replies to the initial content message and her client includes a notification that her state is <active/>:</p>
<examplecaption="Contact's Client Sends Content Message Reply With <active/> Notification"><![CDATA[
<p>And so the conversation continues. After a while, Juliet asks a question that brings Romeo up short. Romeo begins composing a reply to Juliet's heartfelt question, and his Jabber client notifies Juliet that he is composing a reply.</p>
<p>Romeo realizes his reply is too rash and pauses to choose the right words; after some (configurable) time period, his Jabber client senses the delay and sends a state of <paused/>.</p>
<p>When Juliet returns to her computer on the balcony, she finds the new message from Romeo. When she finishes her reply, her client includes both an <active/> notification and the new Thread ID with the body of her reply:</p>
<p>A client that receives a chat state notification should expect that it may never receive another message or chat state notification from the other entity (e.g., because the other entity crashes or goes offline) and should plan accordingly.</p>
<p>The states of a chat thread may reveal information about a user's interaction with his or her computer, including his or her physical presence; such information SHOULD NOT be revealed to conversation partners who are not trusted to know such information. Client implementations MUST provide a mechanism that enables the user to disable chat state notifications if desired.</p>