<remark><p>Spelling, grammar, and clarification edits, including section clarifications recommended from public discussion. Interop with XEP-0308 message correction.</p></remark>
<p>Real-time text is text transmitted instantly while it is being typed or created. The recipient can immediately read the sender's text as it is written, without waiting. It allows text to be used as conversationally as a telephone conversation, including in situations where speech is not practical (e.g., environments that must be quiet, environments too noisy to hear, restrictions on phone use, situations where speaking is a privacy or security concern, and/or when participant(s) are deaf or hard of hearing). It is also used for transmission of live speech transcription.</p>
<note>RFC 4103: RTP Payload for Text Conversation <<linkurl="http://tools.ietf.org/html/rfc4103">http://tools.ietf.org/html/rfc4103</link>>.</note> real-time text.</li>
<li>Instant messaging enhancements, including a <spanclass="ref"><strong><linkurl="http://tap.gallaudet.edu/rtt/">Gallaudet University</link></strong></span>
<note>Gallaudet University Technology Access Program collaboration project: Real-Time Text <<linkurl="http://tap.gallaudet.edu/rtt/">http://tap.gallaudet.edu/rtt/</link>>.</note> collaboration.</li>
<note>RFC 6443: Framework for Emergency Calling Using Internet Multimedia <<linkurl="http://tools.ietf.org/html/rfc6443">http://tools.ietf.org/html/rfc6443</link>>.</note>).</li>
<p>For a visual animation of real-time text, see <spanclass="ref"><strong><linkurl="http://www.realtimetext.org">Real-Time Text Taskforce</link></strong></span>
<note>Real-Time Text Taskforce, a foundation for real-time text standardization <<linkurl="http://www.realtimetext.org">http://www.realtimetext.org</link>>.</note>.</p>
<li>Support transmission and reproduction of the original intervals between key presses, to preserve look-and-feel of typing independently of transmission intervals.</li>
<li>Allow use within gateways to interoperate with other real-time text protocols, including <strong>RFC 4103</strong> and <spanclass="ref"><strong><linkurl="http://www.itu.int/rec/T-REC-T.140">ITU-T T.140</link></strong></span>
<note>ITU-T T.140: Protocol for multimedia application text conversation <<linkurl="http://www.itu.int/rec/T-REC-T.140">http://www.itu.int/rec/T-REC-T.140</link>>.</note>.</li>
<li>Allow XMPP applications to be able to implement <spanclass="ref"><strong><linkurl="http://www.itu.int/rec/T-REC-F.703">ITU-T Rec. F.703</link></strong></span>
<note>ITU-T Rec. F.703: Multimedia conversational services <<linkurl="http://www.itu.int/rec/T-REC-F.703">http://www.itu.int/rec/T-REC-F.703</link>>.</note> Total Conversation standard for simultaneous voice, video, and real-time text.</li>
<li>Be suitable for transcription services and (when coupled with voice at user's choice) for TTY/text telephone alternatives, relay services, and captioned telephone systems.</li>
<dl><di><dt>action element</dt><dd>An XML element that represents a single real-time message edit, such as text insertion or deletion.</dd></di>
<di><dt>character</dt><dd>A single Unicode code point. See <linkurl="#unicode_character_counting">Unicode Character Counting</link>.</dd></di>
<di><dt>real-time</dt><dd>A conversational latency of less than 1 second, as defined by <spanclass="ref"><strong><linkurl="http://www.itu.int/rec/T-REC-F.700">ITU-T Rec. F.700</link></strong></span>
<di><dt>real-time text</dt><dd>Text transmitted instantly while it is being typed or created, to allow recipient(s) to immediately read the sender's text as it is written, without waiting.</dd></di>
<di><dt>real-time message</dt><dd>Recipient's real-time view of the sender's message still being typed or created.</dd></di>
<di><dt>RTT</dt><dd>Acronym for real-time text.</dd></di>
<di><dt>simultaneous login</dt><dd>Multiple simultaneous sessions, on multiple clients, using the same login (Jabber Identifier).</dd></di></dl>
<p>Real-time text is transmitted via an <rtt/> child element of a <message/> stanza. The <rtt/> element is transmitted at regular intervals by the sender client while a message is being composed. This allows the recipient to see the latest message text from the sender, without waiting for the full message to be sent in a <body/> element.</p>
<p>This is a basic example of a <strong>real-time message</strong> "Hello, my Juliet!” transmitted in real-time while it is being typed, before a final message delivery in a <body/> element (to remain <linkurl="#backwards_compatible">Backwards Compatible</link>):</p>
<p>The <rtt/> element contains one or more child elements that represent <linkurl="#realtime_text_actions">Real-Time Text Actions</link> such as text being appended, inserted, or deleted. Example 1 illustrates only the <t/><strong>action element</strong>, which appends text to the end of a message.</p>
<p>Transmission of the <rtt/> element occurs at a regular <linkurl="#transmission_interval">Transmission Interval</link> whenever the sender is actively composing a message. If there are no changes to the message since the last transmission, no transmission occurs.</p>
<p>There MUST NOT be more than one <rtt/> element per <message/> stanza.</p>
<p>The namespace of the <rtt/> element is “urn:xmpp:rtt:0”.</p>
<p>This REQUIRED attribute is a counter to maintain synchronization of real-time text. Senders MUST increment this value by 1 for each subsequent edit to the same real-time message, including when appending new text. Receiving clients MUST monitor this 'seq' value as a lightweight verification on the synchronization of real-time text messages. The bounds of 'seq' is 31-bits, the range of positive values for a signed 32-bit integer. See <linkurl="#keeping_realtime_text_synchronized">Keeping Real-Time Text Synchronized</link>.</p>
<p>If the 'event' attribute is omitted, event="edit" is assumed as the default. When <linkurl="#action_elements">Action Elements</link> are used (e.g., text appends, insertions and deletions), the <rtt/> element MAY contain one or more of any action elements, in any order. When action elements are not allowed, the <rtt/> element MUST be empty. Recipient clients MUST ignore <rtt/> elements containing unrecognized 'event' values.</p>
<p>This attribute is used only if &xep0308; is implemented along with this specification. See <linkurl="#usage_with_last_message_correction">Usage with Last Message Correction</link> to enable real-time text during editing of the previous message.</p>
<li><p><strong>Initialize a new real-time message: <rtt event="new"/> and <rtt event="reset"/></strong><br/>
Sender clients MUST use an <rtt/> element containing either event="new" or event="reset" in the first transmission of a new real-time message. Recipient clients MUST initialize a new blank real-time message for display, and then process all <linkurl="#action_elements">Action Elements</link> (e.g., text insertions and deletions) included within the <rtt/> element. If a real-time message already exists from the same sender in the same chat session, its content MUST be seamlessly replaced (i.e., cleared prior to immediately processing action elements).</p></li>
<li><p><strong>Both <rtt event="new"/> and <rtt event="reset"/> are logically identical to recipients, except for presentation:</strong><br/>
For recipients, these differ only for optional presentation purposes (e.g., highlighting newly started incoming messages). Senders SHOULD use event="new" when sending the first text of a new message (e.g., the first key presses), and only use event="reset" when doing <linkurl="#message_refresh">Message Refresh</link> or <linkurl="#simple_realtime_text">Simple Real-Time Text</link>. See <linkurl="#keeping_realtime_text_synchronized">Keeping Real-Time Text Synchronized</link>.</p></li>
<li><p><strong>Sending modifications of a real-time message: Outgoing <rtt event="edit"/> or <rtt/><br/></strong>Sender clients SHOULD transmit this element at a regular <linkurl="#transmission_interval">Transmission Interval</link> while the message is being modified. The 'seq' attribute MUST increment by 1 for every consecutive modification transmitted. See <linkurl="#sending_realtime_text">Sending Real-Time Text</link>.</p></li>
<li><p><strong>Receiving modifications of a real-time message: Incoming <rtt event="edit"/> or <rtt/><br/></strong>Recipient clients must verify that the 'seq' attribute increments by 1 in consecutively received <rtt/> elements from the same sender. If 'seq' increments as expected, the <linkurl="#action_elements">Action Elements</link> (e.g., text insertions and deletions) included with this element MUST be processed to modify the existing real-time message. Otherwise, if 'seq' does not increment as expected, or if no real-time message already exists, the real-time message is considered out of sync and all subsequent modifications MUST be ignored until a new real-time message is initialized via event="new" or event="reset". See <linkurl="#keeping_realtime_text_synchronized">Keeping Real-Time Text Synchronized</link>.</p></li>
Clients MAY use this value to signal activation of real-time text without first starting a real-time message, since the sender may not start composing immediately. The 'seq' attribute is ignored by recipient clients. See <linkurl="#guidelines_for_initiating_realtime_text">Guidelines for Initiating Real-Time Text</link>.</p></li>
Clients MAY use this value to signal deactivation of real-time text. Clients receiving this element SHOULD also discontinue sending <rtt/> elements for the remainder of the same one-to-one chat session (until event="init" is used again), and handle any unfinished real-time messages appropriately (e.g., clearing or saving the message). The 'seq' attribute is ignored by recipient clients. See <linkurl="#guidelines_for_initiating_realtime_text">Guidelines for Initiating Real-Time Text</link>.</p></li>
Sender clients MAY use any new starting value for 'seq' when initializing a real-time message using event="new" or event="reset". Recipient clients receiving such elements MUST use this 'seq' value as the new starting value. A random starting value is RECOMMENDED to improve reliability of <linkurl="#keeping_realtime_text_synchronized">Keeping Real-Time Text Synchronized</link> during <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link> and <linkurl="#simultaneous_logins">Simultaneous Logins</link>.</p></li>
<p>The real-time message is considered complete upon receipt of a standard <body/> element (as qualified by the 'jabber:client' namespace in &xmppim;). The delivered text within <body/> is considered the final message text, and supersedes the real-time message. In the ideal case, the text within <body/> is redundant since it is identical to the final contents of the real-time message.</p>
<p>Sender clients MAY transmit the <body/> element in the same or separate <message/> stanza as the one containing the final <rtt/> element for the real-time message. To continue sending real-time text in subsequent <message/> stanzas, the sender client MUST first initialize a new real-time message according to <linkurl="#processing_rules">Processing Rules</link>.</p>
<p>This real-time text standard simply provides early delivery of text before the <body/> element. The <body/> element continues to follow the XMPP IM specification. In particular, XMPP implementations need to ignore XML elements they do not understand. Clients, that do not support real-time text, will continue to behave normally, displaying complete lines of messages as they are delivered.</p>
<p>For the best balance between interoperability and usability, the default transmission interval of <rtt/> elements for a continuously-changing message SHOULD be approximately <strong>700 milliseconds</strong>. This interval makes it possible for clients to meet <strong>ITU-T Rec. F.700</strong> Section A.3.2.1 for good quality real-time text conversation in many network environments. If a different transmission interval needs to be used, the interval SHOULD be <strong>between 300 and 1000 milliseconds</strong>.</p>
<p>A longer interval will lead to a less optimal user experience. Conversely, a much shorter interval can lead to <linkurl="#congestion_considerations">Congestion Considerations</link>. To provide fluid real-time text, one or more of the following methods can be used:</p>
<li><linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link> for natural typing display, independently of the transmission interval.</li>
<li>Use of <linkurl="#time_critical_and_low_latency_methods">Time Critical and Low Latency Methods</link>, for real-time captioning/speech transcription.</li>
<li>For other options or reduced-precision options, see <linkurl="#lowbandwidth_and_lowprecision_text_smoothing">Low-Bandwidth and Low-Precision Text Smoothing</link>.</li>
<p>The <rtt/> element MAY contain one or more <strong>action elements</strong> representing real-time text operations, including text being appended, inserted, or deleted.</p>
<p>Many chat clients allow a sender to edit their message before sending (via a Send button, or pressing Enter). The seamless inclusion of real-time text functionality, in existing client software, needs to preserve the sender's existing expectation of being able to edit their messages. In a chat session with real-time text, the recipient can see the sender compose and edit their message before it is completed.</p>
<p>These elements are kept compact in order to save bandwidth, since a single <rtt/> element can contain a large number of action elements (e.g., during <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>). See <linkurl="#list_of_action_elements">List of Action Elements</link> for details.</p>
The 'p' attribute is an absolute position value, as a character position index into the real-time message, where “0” represents the beginning of the message. If 'p' is omitted, the default value of 'p' MUST point to the end of the message (i.e., 'p' is set to the current length of the real-time message).</p></li>
<li><p>For the purpose of this specification, the word "character" represents a single Unicode code point. See <linkurl="#unicode_character_counting">Unicode Character Counting</link>.</p></li>
<li><p>Senders MUST NOT use negative values for any attribute, nor use 'p' values bigger than the current message length. However, recipients receiving such values MUST clip negative values to “0”, and clip excessively high 'p' values to the current length of the real-time message. Modifications only occur within the boundaries of the current real-time message.</p></li>
<p>Recipients MUST be able to process all <t/> and <e/> action elements for incoming <rtt/> transmissions, even if senders do not use all of these for outgoing <rtt/> transmissions (e.g., <linkurl="#simple_realtime_text">Simple Real-Time Text</link>). Support for <w/> is RECOMMENDED for both senders and recipients, in order to accommodate <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>. Recipients MUST ignore unexpected or unsupported elements within <rtt/>, while continuing to process subsequent action elements. Compatibility is ensured via <linkurl="#namespace_versioning">Namespace Versioning</link>. Action elements are immediate child elements of the <rtt/> element, and are never nested. See examples in <linkurl="#use_cases">Use Cases</link>.</p>
<em>Note: Text can be any</em><em>subset of text allowed in the <body/> element of a <message/>. If <t/> is empty or blank, no text modification takes place.</em></p>
<p>Append specified <strong>text</strong> at the end of message. ('p' defaults to message length).<br/>
<em>Note: This action element is the minimum support REQUIRED for sender clients (i.e., speech transcription, chat bots, and <linkurl="#simple_realtime_text">Simple Real-Time Text</link> are still possible without supporting additional action elements).</em></p>
<p>Supports the behavior of backspace key presses. Text is removed towards beginning of the message. This element is also used for all delete operations, including the backspace key, the delete key, and text block deletes.<br/>
<em>Note: Excess backspaces MUST be ignored by the receiving client. Thus, text is backspaced only to the beginning of the message, in situations where n is larger than p.</em></p>
<p>Allow for the transmission of intervals, between real-time text actions, to recreate the pauses between key presses. See <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>.</p>
<p>Wait 'n' milliseconds before processing the next action element. This pause MAY be approximate, and not necessarily be of millisecond precision. Sender clients SHOULD NOT send large 'n' values that exceed the average <linkurl="#transmission_interval">Transmission Interval</link>. Recipient clients MAY selectively shorten or ignore the pauses ('n') in <w/> action elements to avoid lag in a chat session. Situations such as network congestion can result in a surge of <w/> elements where the total of pauses exceeds a transmission interval cycle. See <linkurl="#receiving_realtime_text">Receiving Real-Time Text</link>.</p>
<p>During a chat session, real-time text needs to be identical on both the sender and recipient ends. A missing <rtt/> transmission can represent missing text or missing edits. Also, recipients can connect after the sender has already started composing a message. To address this, a <linkurl="#message_refresh">Message Refresh</link> mechanism allows recipient clients to recover the sender's real-time message that is actively in-progress. This synchronizes real-time text in many situations, including:</p>
<li><linkurl="#simultaneous_logins">Simultaneous Logins</link> (e.g., user switching between devices/clients or between windows/tabs in a client).</li>
<li>During <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link> (e.g., participants joining/leaving while other participants are composing).</li>
<li>After message stanzas are lost in transit (e.g., <linkurl="#congestion_considerations">Congestion Considerations</link>).</li>
<p>Recipient clients MUST keep track of separate real-time messages on a per-contact basis, including tracking independent '<linkurl="#seq">seq</link>' attribute values. Recipient clients MAY track incoming <rtt/> elements per bare JID &LOCALBARE; to keep only one real-time message per contact. The remainder of this section automatically handles conflicting <rtt/> elements (e.g., typing coming concurrently from separate <linkurl="#simultaneous_logins">Simultaneous Logins</link>, contrary to the common case of one typist per contact). Alternatively, recipient clients MAY track incoming <rtt/> elements per full JID &LOCALFULL; and/or per <thread/>, to keep multiple separate real-time messages for the same contact. For more information about <thread/>, see &xep0201;.</p>
<p>By following <linkurl="#processing_rules">Processing Rules</link>, the recipient client creates a new real-time message when receiving <rtt event="new"/> or <rtt event="reset"/>. Thereafter, when receiving text modifications (i.e., <rtt event="edit"/> or <rtt/> without an 'event' attribute):</p>
<p>Loss of sync occurs during receiving text modifications if the 'seq' attribute does not increment by 1 as expected, or if no real-time message exists. In this case:</p>
<li>An <rtt/> element with an 'event' attribute of 'new' or 'reset' (e.g., new message, or <linkurl="#message_refresh">Message Refresh</link>).</li>
<p>A message refresh is the sender's partially composed text being (re)transmitted via <rtt event="reset"/>. The recipient client(s) can seamlessly redisplay the real-time message as a result. This allows real-time text to resume quickly, without waiting for senders to start a new message:</p>
<p>The message refresh SHOULD be transmitted at intervals during active typing or composing. The RECOMMENDED interval is 10 seconds. This interval is frequent enough to minimize user waiting time, while being infrequent enough to not cause a significant bandwidth overhead. This interval can be varied, or be set to a longer time period, in order to reduce average bandwidth (e.g., long messages, infrequent or minor message changes). To save bandwidth, message refreshes SHOULD NOT occur continuously while the sender is idle. To allow quicker resumption of real-time text, sender clients MAY adjust the timing of the message refresh to occur right after any of the following additional events:</p>
<li>When the recipient starts sending messages from a different full JID (e.g., switched clients);</li>
<li>When the recipient presence changes to a more available state (e.g., <show/> value of “chat”);</li>
<li>When the sender resumes composing after an extended pause (e.g., recipient may have cleared <linkurl="#stale_messages">Stale Messages</link>);</li>
<li>When the conversation is unlocked (e.g., section 5.1 of XMPP IM);</li>
<p>If the recipient already has an existing real-time message from the sender, <linkurl="#processing_rules">Processing Rules</link> require that the real-time message MUST be seamlessly replaced. Thus, if the recipient is successfully <linkurl="#staying_in_sync">Staying In Sync</link>, the recipient user sees no visible effect since the text contained within <rtt event="reset"/> is a duplicate of the existing real-time message. If the recipient client was out of sync (<linkurl="#recovery_from_loss_of_sync">Recovery From Loss of Sync</link>) or it has no real-time message, the recipient user sees the real-time message immediately “catch up”.</p>
<p>Note: The use of <rtt event="reset"/> is not limited to message refresh, as it can contain any number of <linkurl="#action_elements">Action Elements</link> in any order. Sender clients MAY combine a message refresh with additional action elements (e.g., re-transmitting a whole message in one <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link>, followed by some additional action elements, such as additional typing or backspacing, to seamlessly allow <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>).</p>
<p>Incorrectly generated <linkurl="#action_elements">Action Elements</link> and <linkurl="#attribute_values">Attribute Values</link> can lead to inconsistencies between the sender and recipient during real-time editing. The Unicode characters of the real-time text need to be transmitted unaltered from the sender to the recipient, without unexpected modifications after sender pre-processing. This is the chain between the sender's creation of real-time text, to the recipient's processing of real-time text. Unaltered transmission of Unicode characters is possible with sender pre-processing, as long as the transmission from the sender to the recipient remains standards-compliant, including compliant XML processors and compliant XMPP servers.</p>
<p>If unexpected Unicode inconsistencies occur during real-time message editing, the recipient client will normally recover the message upon receiving a <linkurl="#body_element">Body Element</link> or a <linkurl="#message_refresh">Message Refresh</link>.</p>
<p>For this specification, a "character" represents a single Unicode code point. This is the same definition used in section 1.1 of <spanclass="ref"><strong><linkurl="http://tools.ietf.org/html/rfc5198">RFC 5198</link></strong></span>
<note>RFC 5198: Unicode Format for Network Interchange <<linkurl="http://tools.ietf.org/html/rfc5198">http://tools.ietf.org/html/rfc5198</link>>.</note>. For platform-independent interoperability of <linkurl="#action_elements">Action Elements</link>, calculations on <linkurl="#attribute_values">Attribute Values</link> (<em><strong>p</strong></em> and <em><strong>n</strong></em>) MUST be based on counts of Unicode code points.</p>
<p>Many platforms use different internal encodings (i.e., string formats) that are different from the transmission encoding (UTF-8). These factors need to be considered:</p>
<li><p>Multiple Unicode code points (e.g., combining marks, accents) can form a combining character sequence. This can occur in situations where there isn't a visually equivalent composite character of a single code point (e.g., when doing Unicode normalization).<br/>
<li><p>XMPP transmission uses UTF-8, which uses a variable number of bytes per Unicode code point.<br/><em>Action elements operate on Unicode code points as a whole, not on separate bytes.</em></p></li>
<p>Lengths and positions in <linkurl="#attribute_values">Attribute Values</link> are relative to the internal Unicode text of the real-time message, independently of the directionality of actual displayed text. As a result, any valid Unicode text direction can be used with real-time text (right-to-left, left-to-right, and bidirectional). One way for implementers to visualize this, is to simply visualize Unicode text as an array of individual code points, and treat <linkurl="#attribute_values">Attribute Values</link> as array indexes.</p>
</section3>
<section3topic="Guidelines for Senders"anchor="guidelines_for_senders">
<p>Sender clients MUST generate real-time text (<linkurl="#action_elements">Action Elements</link> and <linkurl="#attribute_values">Attribute Values</link>) based on the plain text version of the sender's message with pre-processing completed. This is separate from and concurrent to any displayed presentation of the same message (e.g., formatting, emoticon graphics, &xep0071;).</p>
<p>Pre-processing before generating real-time text includes Unicode normalization, conversion of emoticons graphics to text, removal of illegal characters, line-break conversion, and any other necessary text modifications. For Unicode normalization, sender clients SHOULD ensure the message is in <spanclass="ref"><strong><linkurl="http://www.unicode.org/reports/tr15/">Unicode Normalization Form C</link></strong></span>
<note>Unicode Standard Annex #15: Unicode Normalization Forms <<linkurl="http://www.unicode.org/reports/tr15/">http://www.unicode.org/reports/tr15/</link>>.</note> ("NFC"), as recommended within section 3 of <strong>RFC 5198</strong>, and within many other standards such as Canonical XML 1.0.</p>
<p>If Unicode combining character sequences (e.g., letter with multiple accents) are used for <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link>, then complete combining character sequences SHOULD be sent. In situations where modifications are required to an existing combining character sequence (e.g., adding an additional accent), an <linkurl="#element_e_erase_text">Element <e/>– Erase Text</link> SHOULD be used to delete the existing combining character sequence, before transmitting a complete replacement sequence via the <t/> element. (However, recipients SHOULD NOT assume this behavior from sending clients. See <linkurl="#guidelines_for_recipients">Guidelines for Recipients</link>.)</p>
<p>For the purpose of calculating <linkurl="#attribute_values">Attribute Values</link>, any line breaks MUST be treated as a single character. Conversion of line breaks into a single LINE FEED U+000A is REQUIRED for XML processors, according to section 2.11 of <spanclass="ref"><strong><linkurl="http://www.w3.org/TR/xml/">XML</link></strong></span>
<p>For <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link>, text MUST be obtained using compliant XML processing (including entities converted to characters). Recipient clients SHOULD ensure that the received text is in Unicode Normalization Form C ("NFC"). After this, recipient clients MUST NOT do any other modifications to resulting real-time messages. This is to allow accurate processing of subsequent <linkurl="#action_elements">Action Elements</link> and <linkurl="#attribute_values">Attribute Values</link> (the recipient client can separately process/modify a copy of the same real-time message text, if necessary for the purpose of display presentation).</p>
<p>It is possible for sender clients to send <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link> with an incomplete combining character sequence (e.g., combining mark(s) without a Unicode base character). This is valid when extending an existing combining character sequence into a longer valid complete combining character sequence (e.g., adding an additional accent mark). It is also possible for senders to send <linkurl="#element_e_erase_text">Element <e/>– Erase Text</link> to remove code points from an existing combining character sequence, into a shorter valid complete combining character sequence (e.g., removing an accent mark). In all cases, recipient clients MUST process these elements in accordance to <linkurl="#action_elements">Action Elements</link>.</p>
<p>If a client supports this real-time text protocol, it MUST advertise that fact in its responses to &xep0030; information requests ("disco#info") by returning a feature of ‘<strong>urn:xmpp:rtt:0</strong>’.</p>
<p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
<p>See <linkurl="#guidelines_for_initiating_realtime_text">Guidelines for Initiating Real-Time Text</link> for more information, including implicit discovery.</p>
<section2topic="Support for Groupchat"anchor="support_for_groupchat">
<p>Real-time text MAY also be used with <strong>Multi-User Chat</strong>. Before transmitting <rtt/> elements to a groupchat room, clients MUST follow section 17.1.1 of <strong>XEP-0045</strong> to verify that the service allows any extension or that ‘urn:xmpp:rtt:0’ is listed as an allowable namespace.</p>
<p>Services explicitly allowing this extension MUST follow section 17.1.1 of <strong>XEP-0045</strong> to include ‘urn:xmpp:rtt:0’ as an allowable namespace.</p>
<p>See <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link>.</p>
<p>Some clients can choose to send outgoing real-time text at all times by default. Other clients might choose to do user-initiated activation (e.g., via a button). These guidelines provide interoperability between clients that use different methods of initiating real-time text.</p>
<p>For one-to-one chats, it can be beneficial for clients to easily synchronize the enabling/disabling of real-time text. Upon receiving incoming real-time text, recipient clients MAY automatically do an appropriate response, such as:</p>
<ul>
<li>Activate immediately (begin transmitting <rtt/> elements too); or</li>
<li>Activate after user confirmation prompt (for <linkurl="#privacy">Privacy</link> considerations); or</li>
<li>Display only incoming real-time text (e.g., <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link> participants control their own outgoing real-time text).</li>
<p>To prevent transmission loops, senders SHOULD NOT transmit <rtt event="init"/> automatically in response to incoming <rtt event="init"/>. Upon sending any <rtt/> elements (except <rtt event="cancel"/>), real-time text is considered activated on the sender side and it is not necessary to transmit <rtt event="init"/> again for the chat session while real-time text is active.</p>
<p>For any client, the preferred first <rtt/> element to send is <rtt <linkurl="#event">event</link>="init"/> as it can quickly signal activation of real-time text, without waiting for the sender to begin composing a new message, and since it is usable regardless of discovery. Also, if the sender was already composing a message when activating real-time text, <linkurl="#message_refresh">Message Refresh</link> handles this situation.</p>
<p>While explicit discovery is REQUIRED where possible (see <linkurl="#determining_support">Determining Support</link>), it is not possible to use explicit discovery when the sender does not share a presence subscription with the the contact and knows only their bare JID (e.g., they have yet to receive stanzas from the contact). In this case, the sender client MAY implicitly request and discover the use of real-time text, by sending <rtt event="init"/> upon activation. Senders SHOULD NOT send any further <rtt/> elements, until support is confirmed either by incoming <rtt/> elements or via discovery. Implicit discovery makes it possible to use real-time text as an enhancement to &xep0085; (Section 5.1), during all situations where it can be used (e.g., when an actively-composing sender appears invisible/offline to the recipient). See <linkurl="#usage_with_chat_states">Usage with Chat States</link>.</p>
<p>Real-time text MAY be deactivated by transmitting <rtt <linkurl="#event">event</link>="cancel"/>, or simply by ending the chat session. Recipient clients SHOULD respond to deactivation with appropriate response(s), including:</p>
<li>Stop transmitting <rtt/> elements as well (not applicable to <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link>); and</li>
<p>Any client MAY also send an <rtt event="cancel"/> when ending the chat session (e.g., user closes a chat window) or when deactivating real-time text while continuing the chat session. Clients receiving <rtt event="cancel"/> do not need to also transmit <rtt event="cancel"/> back.</p>
<p>Senders deactivating real-time text while in the middle of composing a message can continue composing their message without real-time text being sent. Completed messages continue to be transmitted normally via the <linkurl="#body_element">Body Element</link>. Recipients that no longer receive further real-time updates, MAY handle the incomplete sender's real-time message appropriately (e.g., clearing/greying-out/saving the message, or using <linkurl="#stale_messages">Stale Messages</link> handling).</p>
<p>After deactivation, any client MAY reactivate real-time text again using <rtt event="init"/>.</p>
<p>If a long <linkurl="#transmission_interval">Transmission Interval</link> is used without <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>, then incoming text will appear in intermittent bursts if the display of text is not smoothed. This hurts user experience of real-time text.</p>
<p>For high quality presentation of real-time text, the original look-and-feel of typing can be preserved independently of the transmission interval. This is achieved using <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> between other <linkurl="#action_elements">Action Elements</link>. Sender clients can transmit the length of pauses between key presses, and send multiple key presses in a single <message/> stanza. Recipient clients that process <w/> elements are able to display the sender's typing smoothly without sudden bursts of text. See <linkurl="#examples_of_key_press_intervals">Examples of Key Press Intervals</link>.</p>
<p>When key press intervals are preserved at high precision, all subtleties of typing are preserved, including the 'mood' (calm typing versus panicked or emphatic typing, etc.). Much as Voice over IP (VoIP) allows accurate packet transmission of sound, this spec allows accurate packet transmission of original typing look-and-feel. This enables the real-time feel of typing over virtually any network connection, without requiring frequent transmission intervals. Look and feel of typing is also preserved over variable latency connections including &xep0206;, mobile phone, satellite and long international connections with heavy packet-bursting tendencies.</p>
<p>There are specialized situations such as live transcriptions and captioning (e.g., transcription service, closed captioning provider, captioned telephone, Communication Access Realtime Translation (CART), relay services) that demand low latency transmission. Such systems typically use voice recognition and/or stenotype machines, which output text in word or phrase bursts rather than a character at a time. It can be acceptable for senders with bursty output to immediately transmit word or phrase bursts of text without buffering, as long as the average stanza rate is not excessive. This eliminates any lag caused by the <linkurl="#transmission_interval">Transmission Interval</link>. It is not necessary to transmit <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> for real-time transcription.</p>
<p>Some software platforms (e.g., JavaScript, BOSH, mobile devices) may have low-precision timers that impact <linkurl="#transmission_interval">Transmission Interval</link> and/or <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>. Clients can optimize for bandwidth, performance and/or screen repaints by eliminating, merging, or ignoring <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> selectively, especially those containing shorter intervals. In addition, it is acceptable for the transmission interval of <rtt/> to vary, either intentionally for optimizations, or due to precision limitation, preferably within the range recommended by <linkurl="#transmission_interval">Transmission Interval</link>. Compression can also be used to reduce bandwidth (e.g., TLS compression or &xep0138;).</p>
<p>Clients can choose to implement alternate text-smoothing methods, such as adaptive-rate character-at-a-time output, and/or word buffering for incoming real-time text. Word buffering prevents most typing mistakes from being displayed, which can be a useful mode of operation for certain recipients who may dislike watching the sender's typing mistakes.</p>
<p>Recipient clients can choose to display a remote cursor within incoming real-time messages. A remote cursor is a separate cursor/caret indicator within incoming real-time messages, separate of the user's local cursor for outgoing messages. This can improve usability of real-time text, since it becomes easier for a recipient to observe the sender's real-time message edits. For clients that do not implement a remote cursor, skip this section.</p>
<p><linkurl="#action_elements">Action Elements</link> use only absolute positioning (relative positions are not used by this specification), so clients do not need to remember the position value from previous action elements. Recipient software can calculate the remote cursor position as follows:</p>
<li><p>Upon receiving <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link>, the cursor position is the 'p' attribute plus the length of the text being inserted. The cursor position is put at the end of the inserted text.<br/>
<li><p>Upon receiving <linkurl="#element_e_erase_text">Element <e/>– Erase Text</link>, the cursor position is the 'p' attribute minus the 'n' attribute.<br/>
<li><p>Upon receiving an empty <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link> (e.g., <t p='#'/> or <t p='#'></t>), the cursor position is the 'p' attribute and no text modification is done. Senders can send these elements when only the cursor position has changed (e.g., arrow keys, mouse repositioning). These are non-operative elements on recipients that do not implement a remote cursor.</p></li>
<p>This section lists several possible methods of generating real-time text for transmission. For most situations, the preferred methodology is <linkurl="#monitoring_message_changes_instead_of_key_presses">Monitoring Message Changes Instead Of Key Presses</link>.</p>
<section3topic="Monitoring Message Changes Instead Of Key Presses"anchor="monitoring_message_changes_instead_of_key_presses">
<p>Experience has found that the most reliable method for generating real-time text, is to monitor for <strong>text changes</strong> to the sender’s message entry field, instead of key press events. Text change events have the following advantages:</p>
<ul>
<li>It captures all typing, including edits and deletes.</li>
<li>It captures copy & paste operations, as well as edits made via a pointing device.</li>
<p>During a text change event, the sender’s current message text can be compared to the old message text from the previous text change event. The difference in text, between consecutive text change events, is typically a one character difference (e.g., key press) or one text block difference (e.g., auto-correct, cut, paste). In order to calculate what text changes took place, the first changed character and the last changed character are determined. From this, it is simple to generate <linkurl="#action_elements">Action Elements</link> for a single text block deletion and/or insertion. In addition, if <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link> is supported, then <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> records the time elapsed between text change events.</p>
<li><p>Monitor for text changes in the sender’s message. Whenever a text change event occurs, compute action element(s) and append these action element(s) to a buffer. Repeating this step during every text change event, is equivalent to recording a small sequence of typing.</p></li>
<li><p>During every <linkurl="#transmission_interval">Transmission Interval</link>, all buffered action elements are transmitted in <rtt/> element in a <message/> stanza. This is equivalent to transmitting a small sequence of typing at a time.</p></li>
<li><p>If there are no message changes occurring, no unnecessary transmission takes place.</p></li>
<p>Real-time text can be generated via monitoring key presses. However, this does not have the advantages of <linkurl="#monitoring_message_changes_instead_of_key_presses">Monitoring Message Changes Instead Of Key Presses</link>. Care needs be taken with automatic changes to the message, generated by means other than key presses. This includes spell check auto-correct, copy and pastes, transcription, input method editors, and multiple key presses required to compose a character (i.e., accents). Key press events can miss these text changes, and this can potentially cause incorrect real-time text to be transmitted.</p>
<p>The use of <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link> without any attributes, simply appends text to the end of a message, while the use of <linkurl="#element_e_erase_text">Element <e/>– Erase Text</link> without any attributes, simply erases text from the end of the message. This sending method can also be useful for special-purpose clients where mid-message editing capabilities are not used (e.g., simple transcription, news tickers, relay services, captioned telephone).</p>
<p>It is possible for sender clients to use <linkurl="#message_refresh">Message Refresh</link> to simply re-transmit the whole real-time message, as a method of transmitting text changes. The advantage is very simple implementation. Disadvantages can include the lack of <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>, and extra bandwidth consumption that can occur with longer messages, unless stream compression is used. The below illustrates transmission of the real-time message “<strong>Hello there!</strong>” at a regular <linkurl="#transmission_interval">Transmission Interval</link> while the sender is typing.</p>
<p>Note: The 'seq' attribute can be restarted at any value with <rtt event="reset"/> and <rtt event="new"/>. See <linkurl="#processing_rules">Processing Rules</link>.</p>
<p>In order to allow <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link> in incoming real-time text, recipient clients can do the following:</p>
<li><p>Upon receiving <linkurl="#action_elements">Action Elements</link> in incoming <rtt/> elements, they are added to a queue in the order they are received. This provides immunity to variable network conditions, since the queueing action will smooth out incoming transmission (e.g., receiving new <rtt/> while still processing action elements from a delayed <rtt/>).</p></li>
<li><p>The recipient client processes action elements in the queue in sequential order, including pauses from <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link>, if supported. This is equivalent to playing back the sender's original typing.</p></li>
<p>If <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> is supported, excess lag in incoming real-time text can occur when delayed <rtt/> elements get delivered (e.g., congestion, intermittent wireless reception). To avoid delayed presentation of real-time text, the recipient client needs to speed up processing of action elements. This can be accomplished through a variety of techniques, such as shortening the pauses ('n' value) in <w/> elements, ignoring excess <w/> elements, immediately outputting action elements that are still queued, and/or keeping action elements from a limited number of <rtt/> elements queued (immediately outputting any prior action elements). This allows lagged real-time text to catch up more quickly.</p>
<p>Upon receiving a <linkurl="#body_element">Body Element</link> indicating a completed message, it is acceptable for the full message text from <body/> to be displayed immediately in place of the real-time message, and discard any unprocessed action elements. This prevents any delay in displaying the final message delivery, however, this may cause a sudden surge of text in some situations.</p>
<p>If the <w/> element is not supported, receiving clients can use an alternate text-smoothing method in order to <linkurl="#avoid_bursty_text_presentation">Avoid Bursty Text Presentation</link> (e.g., time-smoothed progressive output of received real-time text).</p>
<p>A large sequence of action elements can result in an <rtt/> larger than the size of a message <body/>. This can occur normally during fast typing when <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link> during small messages. However, if the <rtt/> element becomes unusually large (e.g., macros, multiple copy and pastes, leading to an <rtt/> exceeding one kilobyte) a <linkurl="#message_refresh">Message Refresh</link> can instead be used, in order to save bandwidth. (Stream compression is another approach.)</p>
<p>Clients can limit the length of the text input for the sender's message, in order to keep the size of <message/> stanzas reasonable, including during <linkurl="#message_refresh">Message Refresh</link>. Also, large <rtt/> elements might occur in situations such as large copy and pastes. To keep message stanza sizes reasonable, <rtt/> can be transmitted in a separate <message/> than the one containing <body/>.</p>
<p>For clients that send continuous real-time text (e.g., news ticker, captioning, speech transcription, TTY/text telephone gateway), a <linkurl="#body_element">Body Element</link> can be sent and then a new real-time message started immediately after, every time a message reaches a specific size. This allows continuous real-time text without real-time messages becoming excessively large.</p>
<p>Real-time text can be used in conjunction with <strong>Chat State Notifications</strong>. It is best to handle <strong>XEP-0301</strong> and <strong>XEP-0085</strong> transmissions in separate <message/> stanzas. Chat states such as <composing/> or <active/> are sent separately from <rtt/> elements.</p>
<p>Chat states are handled as specified by <strong>XEP-0085</strong>. The continuous transmission of real-time text corresponds to a <composing/> chat state. Therefore, the timing of the <composing/> chat state coincides with the beginning of continuous <rtt/> transmission. </p>
<p>It is possible to use <strong>Last Message Correction</strong> with real-time text. If <strong>XEP-0308</strong> is implemented in concert with this specification, the following rules apply:</p>
<li><p>For all <rtt/> elements transmitted during composing a new message, the '<linkurl="#id">id</link>' attribute of <rtt/> is not used.</p></li>
<li><p>For all <rtt/> elements transmitted during editing of the previous message, the 'id' attribute of <rtt/> matches the 'id' attribute of the old <message/> stanza containing the <body/> text being edited (see 'Business Rules' in <strong>XEP-0308</strong>). This enables recipient clients to display real-time text while the sender is editing the previously-delivered message.</p></li>
<li><p>Senders clients need to transmit a <linkurl="#message_refresh">Message Refresh</link> when transmitting <rtt/> for a different message than the previously transmitted <rtt/> (i.e., the value of the 'id' attribute changes, 'id' becomes included, or 'id' becomes not included). This keeps real-time text synchronized when beginning to edit a previously delivered message versus continuing to compose a new message.</p></li>
<li><p>The <strong>XEP-0301</strong> and <strong>XEP-0308</strong> protocols operate concurrently via separate message stanzas. Thus, a message stanza never simultaneously includes both <rtt/> and <replace/>.</p></li>
<li><p>The <linkurl="#body_element">Body Element</link> delivers a finished new message or a finished message correction (<replace/> is used with <body/> in accordance to <strong>XEP-0308</strong>).</p></li>
<section3topic="Usage with Multi-User Chat"anchor="usage_with_multiuser_chat">
<p>For simplicity, clients can implement real-time text only for one-to-one chat, and not for <strong>Multi-User Chat</strong>. However, it can be appropriate to support <rtt/> elements in groupchat rooms, even if not all participants support real-time text, as long as the service allows it (See <linkurl="#support_for_groupchat">Support for Groupchat</link>).</p>
<p>Participants that enable real-time text during group chat need to keep track of multiple concurrent real-time messages on a per-participant basis. Participants, with real-time text, will see real-time text coming from each participant that has real-time text enabled. Participant clients without real-time text (whether unsupported or turned off) will simply see group chat function normally on a line-by-line basis, since it is <linkurl="#backwards_compatible">Backwards Compatible</link>.</p>
<p>Participants that turn off real-time text for themselves, can simply ignore incoming <rtt/> and not transmit outgoing <rtt/>. Participant clients in groupchat receiving an incoming <rtt <linkurl="#event">event</link>=’cancel’/> needs to keep outgoing transmission unaffected during <linkurl="#deactivating_realtime_text">Deactivating Real-Time Text</link> (otherwise, one participant could deny real-time text between other willing participants).</p>
<p>To minimize on-screen clutter of multiple idle real-time messages, clients can hide idle messages, clear old <linkurl="#stale_messages">Stale Messages</link>, and/or prioritize the display of the most useful real-time messages. Prominent visibility of real-time text can be assigned to recent typists and/or moderators (e.g., classroom teacher, convention speaker). For the same participant logged in multiple times in the same room, see <linkurl="#simultaneous_logins">Simultaneous Logins</link> for handling this situation. In situations of simultaneous typing by a large number of participants, see <linkurl="#congestion_considerations">Congestion Considerations</link>.</p>
<p>In situations where there are multiple sessions from the same JID (i.e., simultaneous logins on multiple clients/devices), transmitting of <rtt/> works in one-to-many situations without any special software support. For many-to-one situations where there is incoming <rtt/> from multiple sessions under the same JID, <linkurl="#keeping_realtime_text_synchronized">Keeping Real-Time Text Synchronized</link> will pause the real-time message upon conflicting <rtt/>, and resume during the next <linkurl="#message_refresh">Message Refresh</link>, presumably from the active session. This provides a seamless system-switching experience. A good implementation of <linkurl="#message_refresh">Message Refresh</link> will improve user experience, regardless of whether or not the client follows &xep0296;. Clients can choose to distinguish the <rtt/> streams (via full JID and/or via <thread/>) and keep multiple concurrent real-time messages similar in manner to <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link>, with the <linkurl="#stale_messages">Stale Messages</link> being timed-out.</p>
<p>There are situations where senders pause typing indefinitely. This can result in recipients displaying a real-time message for an extended time period. It may also be a screen clutter concern during <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link>. In addition, it may be a resource-consumption concern, as part of <linkurl="#congestion_considerations">Congestion Considerations</link>.</p>
<p>It is acceptable for recipients to clear (and/or save) incoming real-time messages that have been idle for an extended time period. There is no specific time-out period defined by this specification. For <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link>, the time-out period might be shorter because of the need to reduce screen clutter. For one-to-one chat sessions, the time-out period might need to be longer to allow reasonable interruptions (i.e., sender pausing during a long phone call or other interruption).</p>
<p>Senders that resume composing a message (i.e., continues a partially-composed message hours later) can do a <linkurl="#message_refresh">Message Refresh</link>, which allows recipients to redisplay the real-time message.</p>
<p>With real-time text, frequent screen updates can occur. Screen updates are a potential performance bottleneck, since fast typists type many key presses per second. Optimizing screen updates is more important on slower platforms. The real-time message might be implemented as a separate window or separate display element.</p>
<p>Battery life considerations are closely related to performance, as the addition of real-time text can have an impact on battery life. If <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link> is supported, then support for <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> needs to be implemented in a battery-efficient manner. The <linkurl="#transmission_interval">Transmission Interval</link> can vary dynamically to optimize for battery life and wireless reception. For devices where screen updates are an unavoidable, inefficient bottleneck, see <linkurl="#lowbandwidth_and_lowprecision_text_smoothing">Low-Bandwidth and Low-Precision Text Smoothing</link> to reduce the number of screen updates per second.</p>
<p>Most of these examples are deliberately kept simple. In complete software implementations supporting key press intervals, transmissions will most resemble the last example, <linkurl="#full_message_including_key_press_intervals">Full Message Including Key Press Intervals</link>. For simplicity, these examples use a bare JID, even in situations where a full JID might be more appropriate.</p>
<p>All three examples shown below result in the same real-time message "<strong>HELLO</strong>" created by writing "<strong>HLL</strong>", backspacing two times, and then "<strong>ELLO</strong>". The action elements are <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link> and <linkurl="#element_e_erase_text">Element <e/>– Erase Text</link>.</p>
<p>The example above sends the misspelled "<strong>HLL</strong>", then <strong><e/><e/></strong> backspaces 2 times, then sends "<strong>HELLO</strong>".</p>
<p>The example above splits the same real-time text over multiple <message/> stanzas, which would occur if the typing was occurring more slowly, over several <linkurl="#transmission_interval">Transmission Interval</link> cycles.</p>
<p>The example above represents moderate typing speed during a normal <linkurl="#transmission_interval">Transmission Interval</link>, such as 700 milliseconds between <message/> stanzas for continuous typing. It illustrates the following <linkurl="#rtt_attributes">RTT Attributes</link>:</p>
Note: In most situations, during normal human typing speeds at a normal <linkurl="#transmission_interval">Transmission Interval</link>, smaller fragments of text will be spread over multiple <rtt/> elements, than these demonstration examples below. See <linkurl="#sending_realtime_text">Sending Real-Time Text</link>.</p>
This example outputs "<strong>Hello Bob, this is Alice!</strong>" then <strong><e n='4' p='9'/></strong> erases 4 characters before character position index 9. The <linkurl="#element_e_erase_text">Element <e/>– Erase Text</link> removes the text " <strong>Bob</strong>" including the preceding space character.</p>
This is because this example outputs "<strong>Hello, this is Alice!</strong>" then the <strong><t p='5'></strong> inserts the specified text " <strong>Bob</strong>" at position 5, using <linkurl="#element_t_insert_text">Element <t/>– Insert Text</link>.</p>
This example outputs "<strong>Hello Bob, tihsd is Alice!</strong>", then <strong><e p='16' n='5'/></strong> erases 5 characters at position 16 in the string of text (which erases the mistyped word "<strong>tihsd</strong>"). Finally, <strong><t p='11'>this</t></strong> inserts the text "<strong>this</strong>" place of the original misspelled word.</p>
<p>This example does not illustrate <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>. Also, it is noted that most situations, during normal typing speeds at a normal <linkurl="#transmission_interval">Transmission Interval</link>, the above series of <linkurl="#action_elements">Action Elements</link> will normally be spread over multiple separate <rtt/> elements.</p>
<section2topic="Examples of Key Press Intervals"anchor="examples_of_key_press_intervals">
<section3topic="Comparison With and Without Intervals"anchor="comparison_with_and_without_intervals">
<p>All examples shown below, result in the same real-time message “<strong>HELLO</strong>”. Only the last example follows <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>.</p>
<p>The above example outputs “<strong>HELLO</strong>” in a single action element (<linkurl="#element_t_insert_text">Element <t/>– Insert Text</link>).</p>
<p>The above example outputs “<strong>HELLO</strong>” in separate action elements for each key press, while also <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>. The <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> specifies the number of milliseconds between key presses, to allow smooth presentation in recipient clients that support <w/> action elements.</p>
<p>This example is a transmission of “Hello there!” while <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>. It illustrates a four-second typing sequence:</p>
<p>The use <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link>, between key presses, allows the receiving client to execute a small pause between action elements. This allows recipient clients to play back the sender's typing fluidly.</p>
<li>Cursor movements via empty <t/> elements. Sender transmission is not essential, but can be desirable for recipient clients supporting an <linkurl="#optional_remote_cursor">Optional Remote Cursor</link>.</li>
<li>Recipient clients that do not support <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link> and/or <linkurl="#optional_remote_cursor">Optional Remote Cursor</link>, will still display this message normally.</li>
<li>The total sum of all values in <linkurl="#element_w_wait_interval">Element <w/>– Wait Interval</link> in one <message/> equal the <linkurl="#transmission_interval">Transmission Interval</link> during periods of continuous typing. This also results in some <w/> interval elements being split between consecutive messages. Although not critical, it can further improve the fluidity of <linkurl="#receiving_realtime_text">Receiving Real-Time Text</link>.</li>
<li>See <linkurl="#monitoring_message_changes_instead_of_key_presses">Monitoring Message Changes Instead Of Key Presses</link> for the best method of implementation.</li>
<p>There are other real-time text formats with interoperability considerations relating to the session setup level, the media transport level, and presentation level. Interoperability specifications between multiple real-time text formats can be found at Real-Time Text Taskforce (R3TF).</p>
<p>Implementers ought to choose the most appropriate real-time text approach for the session control technology in use during a particular session. For example, clients that use XMPP can utilize this <strong>XEP-0301</strong> specification, and clients that use SIP might utilize <strong>RFC 4103</strong>, <spanclass="ref"><strong><linkurl="http://tools.ietf.org/html/rfc5194">RFC 5194</link></strong></span>
<note>RFC 5194: Framework for Real-Time Text over IP Using the Session Initiation Protocol (SIP) <<linkurl="http://tools.ietf.org/html/rfc5194">http://tools.ietf.org/html/rfc5194</link>>.</note> and <strong>ITU-T T.140</strong>. Clients that run on multiple networks, might need to utilize multiple real-time text technologies. To interoperate between incompatible real-time text technologies, gateway servers can transcode between different real-time text technologies, along with other media such as audio and video. This can include TTY and textphones.</p>
<p>In the SIP environment, real-time text is specified in <strong>RFC 4103</strong> and <strong>ITU-T T.140</strong>. SIP is a popular real-time session control protocol, and there are many implementations of real-time text controlled by SIP. This includes emergency services in some regions.</p>
<p>Interoperability considerations include addressing translation, media negotiation and translation, and media transcoding. Transcoding is straightforward between this specification and <strong>T.140</strong> / <strong>RFC 4103</strong>, except for editing in the middle of messages. Text insertions or deletions, occurring far back in the message, can cause a large number of erase operations in <strong>T.140</strong> that consume time and bandwidth. <strong>T.140</strong> specifies the use of ISO 6429 control codes for presentation characteristics, such as text color, that are not supported by this specification. During transcoding, these control codes needs to be filtered off in order to not disturb the presentation of text. Guidance on address translation and conveyance between XMPP and SIP can be found at <spanclass="ref"><strong><linkurl="http://tools.ietf.org/html/draft-ietf-stox-core">IETF stox</link></strong></span>
<note>Interworking between the Session Initiation Protocol (SIP) and the Extensible Messaging and Presence Protocol (XMPP): Addresses and Error Conditions <<linkurl=" http://tools.ietf.org/html/draft-ietf-stox-core">http://tools.ietf.org/html/draft-ietf-stox-core</link>>.</note>.</p>
<p>According to <strong>ITU-T Rec. F.703</strong>, the “Total Conversation” standard defines the simultaneous use of audio, video, and real-time text. For convenience, real-time communication applications can be designed to have automatic negotiation of as many as possible of the three media preferred by the users.</p>
<p>In the XMPP session environment, the Jingle protocol (&xep0166;) is available for negotiation and transport of the more time-critical, real-time audio and video media. Any combination of audio, video, and real-time text can be used together simultaneously.</p>
<p>The primary internationalization consideration involves real-time message editing using <linkurl="#action_elements">Action Elements</link>, where text is inserted and deleted using position and length values. For this, <linkurl="#accurate_processing_of_action_elements">Accurate Processing of Action Elements</link> including correct <linkurl="#unicode_character_counting">Unicode Character Counting</link> will ensure that all possible valid Unicode text can be used via this protocol. This includes text containing multiple scripts/languages, ideographic symbols (e.g., Chinese), right-to-left text (e.g., Arabic), and bidirectional text.</p>
<p>For accessibility considerations, there is an <spanclass="ref"><strong><linkurl="http://www.fasttext.org">International Symbol of Real-Time Text</link></strong></span>
<note>The International Symbol of Real-Time Text <<linkurl="http://www.fasttext.org">http://www.fasttext.org</link>>.</note> to alert users to the existence of this feature.</p>
<p>It is important for users to be made aware of real-time text (e.g., user consent, software notice, introductory explanation). Users of real-time text need to be aware that their typing is now visible in real-time to everyone in the current chat conversation. There can be potential security implications if users copy & paste private information into their chat entry buffer (e.g., a shopping invoice) before editing out the private parts of the pasted text (e.g., a credit card number) and then sending the message. There can also be implications for chat clients that suddenly pop up a chat window upon incoming messages and takes keyboard focus unexpectedly, resulting in the sender typing sensitive information into the wrong window. These accidental privacy risks are also apparent for traditional chat (e.g., accidentally sending a message) but are more immediate for real-time text. With real-time message editing, recipients can watch all text changes that occur in the sender's text, before the sender finishes the message.</p>
<p>Such risks can be avoided by good user interface design. In addition, implementation behaviors and improved education can be added to reduce privacy issues. Examples include showing an introduction upon first activation of feature, special handling for copy and pastes (i.e., preventing them, or prompting for confirmation), recipient confirmation of real-time text via <linkurl="#guidelines_for_initiating_realtime_text">Guidelines for Initiating Real-Time Text</link>, etc.</p>
<p>Real-time text (<rtt/> elements) transmits the content contained within messages. Therefore, a client that encrypts <body/> also needs to encrypt <rtt/> as well:</p>
<li><p>Encryption at the stream level (e.g., TLS) can be used normally with this specification. Stream-level encryption is the most common form of encryption.</p></li>
<li><p>Encryption at the <message/> stanza level (e.g., XEP-0200) can be used for all stanzas containing either <rtt/> or <body/>. It is noted that real-time text can have a higher rate of message stanzas, contributing to additional overhead. See <linkurl="#congestion_considerations">Congestion Considerations</link>.</p></li>
<li><p>Encryption at the <body/> level (e.g., deprecated XEP-0027) does not encrypt <rtt/>. In this case, <rtt/> needs to be encrypted separately. It is preferable to use a broader level of encryption, where possible.</p></li>
<p>It is possible for the timing of individual key presses to be used as a timing attack on encryption. Protection against this is provided by buffering of key presses into a regular <linkurl="#transmission_interval">Transmission Interval</link>. As an additional measure of security, the risk of timing attacks can be further mitigated by padding <rtt/> elements to lengths not clearly related to the number of characters in the message. Alternatively, general XMPP protection mechanisms hiding length information can be applied on the complete message exchange instead of (or in concert with) <rtt/> specific protection mechanisms.</p>
<p>The nature of real-time text can result in more frequent transmission of <message/> stanzas than would otherwise happen in a non-real-time text conversation. This can lead to increased network and server loading of XMPP networks.</p>
<p>Transmission of real-time text can be throttled temporarily during poor network conditions. It is appropriate to use latency monitoring mechanisms (e.g., &xep0184; or &xep0198;) in order to temporarily adjust the <linkurl="#transmission_interval">Transmission Interval</link> of real-time text beyond the recommended range. This results in lagged text (less real-time) but is better than failure during poor network conditions. The use of <linkurl="#message_refresh">Message Refresh</link> can also retransmit real-time text lost by poor network conditions, including stanzas dropped during a network issue or server error. These techniques are useful for mission-critical applications such as next generation emergency services (e.g., text to 9-1-1).</p>
<p>Excess numbers of real-time messages (e.g., during a Denial of Service (DoS) scenario in <linkurl="#usage_with_multiuser_chat">Usage with Multi-User Chat</link>) might cause local resource-consumption issues, which can be mitigated by accelerated time-out of <linkurl="#stale_messages">Stale Messages</link>. Also see &xep0205;.</p>
<p>According to multiple university studies worldwide (including <spanclass="ref"><strong><linkurl="http://seattle.intel-research.net/~davraham/pubs/Avrahami_CSCW_06.pdf">Carnegie Mellon University Study</link></strong></span>
<note>Communication Characteristcs of Instant Messaging: Effects and Predictions of Interpersonal Relationships <<linkurl="http://seattle.intel-research.net/~davraham/pubs/Avrahami_CSCW_06.pdf">http://seattle.intel-research.net/~davraham/pubs/Avrahami_CSCW_06.pdf</link>>.</note>), the average length of instant messages is under 40 characters. The additional incremental bandwidth overhead of real-time text can be very low for an existing XMPP client, especially one already using many extensions. Bandwidth can also be further mitigated using stream compression, to benefit bandwidth-constrained networks (e.g., GPRS, 3G, satellite).</p>
<p>The XMPP Registrar should include "urn:xmpp:rtt:0" in its registry of protocol namespaces (see <<linkurl="http://xmpp.org/registrar/namespaces.html">http://xmpp.org/registrar/namespaces.html</link>>).</p>
<p>If the protocol defined in this specification undergoes a revision that is not fully backwards-compatible with an older version, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of XEP-0053.</p>
<p>The members of the Real-Time Text Taskforce (R3TF), <linkclass="western"href="http://www.realtimetext.org/">www.realtimetext.org</link>, made significant contributions to this specification. Mark Rejhon leads the Jabber/XMPP Taskgroup at R3TF. Members of R3TF who have contributed to this specification include Gunnar Hellstrom, Paul E. Jones, Gregg Vanderheiden, Barry Dingle, and Arnoud van Wijk. Others contributors include Bernard Aboba, Mark Grady, Darren Sturman, Christian Vogler, Norm Williams, and several members from the XMPP Standards Mailing List, including Kevin Smith, Peter Saint-Andre and many others.</p>
<p>The technique of <linkurl="#preserving_key_press_intervals">Preserving Key Press Intervals</link>, otherwise called "natural typing", was created by Mark Rejhon, who is deaf. It is incorporated into this specification in compliance of the XSF's Intellectual Property Rights Policy at <linkclass="western"href="http://xmpp.org/extensions/ipr-policy.shtml">http://xmpp.org/extensions/ipr-policy.shtml</link>.</p>