You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

250 lines
10 KiB

  1. ========
  2. Presence
  3. ========
  4. A description of presence information and visibility between users.
  5. Overview
  6. ========
  7. Each user has the concept of Presence information. This encodes a sense of the
  8. "availability" of that user, suitable for display on other user's clients.
  9. Presence Information
  10. ====================
  11. The basic piece of presence information is an enumeration of a small set of
  12. state; such as "free to chat", "online", "busy", or "offline". The default state
  13. unless the user changes it is "online". Lower states suggest some amount of
  14. decreased availability from normal, which might have some client-side effect
  15. like muting notification sounds and suggests to other users not to bother them
  16. unless it is urgent. Equally, the "free to chat" state exists to let the user
  17. announce their general willingness to receive messages moreso than default.
  18. Home servers should also allow a user to set their state as "hidden" - a state
  19. which behaves as offline, but allows the user to see the client state anyway and
  20. generally interact with client features such as reading message history or
  21. accessing contacts in the address book.
  22. This basic state field applies to the user as a whole, regardless of how many
  23. client devices they have connected. The home server should synchronise this
  24. status choice among multiple devices to ensure the user gets a consistent
  25. experience.
  26. Idle Time
  27. ---------
  28. As well as the basic state field, the presence information can also show a sense
  29. of an "idle timer". This should be maintained individually by the user's
  30. clients, and the homeserver can take the highest reported time as that to
  31. report. Likely this should be presented in fairly coarse granularity; possibly
  32. being limited to letting the home server automatically switch from a "free to
  33. chat" or "online" mode into "idle".
  34. When a user is offline, the Home Server can still report when the user was last
  35. seen online, again perhaps in a somewhat coarse manner.
  36. Device Type
  37. -----------
  38. Client devices that may limit the user experience somewhat (such as "mobile"
  39. devices with limited ability to type on a real keyboard or read large amounts of
  40. text) should report this to the home server, as this is also useful information
  41. to report as "presence" if the user cannot be expected to provide a good typed
  42. response to messages.
  43. Presence List
  44. =============
  45. Each user's home server stores a "presence list" for that user. This stores a
  46. list of other user IDs the user has chosen to add to it (remembering any ACL
  47. Pointer if appropriate).
  48. To be added to a contact list, the user being added must grant permission. Once
  49. granted, both user's HS(es) store this information, as it allows the user who
  50. has added the contact some more abilities; see below. Since such subscriptions
  51. are likely to be bidirectional, HSes may wish to automatically accept requests
  52. when a reverse subscription already exists.
  53. As a convenience, presence lists should support the ability to collect users
  54. into groups, which could allow things like inviting the entire group to a new
  55. ("ad-hoc") chat room, or easy interaction with the profile information ACL
  56. implementation of the HS.
  57. Presence and Permissions
  58. ========================
  59. For a viewing user to be allowed to see the presence information of a target
  60. user, either
  61. * The target user has allowed the viewing user to add them to their presence
  62. list, or
  63. * The two users share at least one room in common
  64. In the latter case, this allows for clients to display some minimal sense of
  65. presence information in a user list for a room.
  66. Home servers can also use the user's choice of presence state as a signal for
  67. how to handle new private one-to-one chat message requests. For example, it
  68. might decide:
  69. "free to chat": accept anything
  70. "online": accept from anyone in my addres book list
  71. "busy": accept from anyone in this "important people" group in my address
  72. book list
  73. API Efficiency
  74. ==============
  75. A simple implementation of presence messaging has the ability to cause a large
  76. amount of Internet traffic relating to presence updates. In order to minimise
  77. the impact of such a feature, the following observations can be made:
  78. * There is no point in a Home Server polling status for peers in a user's
  79. presence list if the user has no clients connected that care about it.
  80. * It is highly likely that most presence subscriptions will be symmetric - a
  81. given user watching another is likely to in turn be watched by that user.
  82. * It is likely that most subscription pairings will be between users who share
  83. at least one Room in common, and so their Home Servers are actively
  84. exchanging message PDUs or transactions relating to that Room.
  85. * Presence update messages do not need realtime guarantees. It is acceptable to
  86. delay delivery of updates for some small amount of time (10 seconds to a
  87. minute).
  88. The general model of presence information is that of a HS registering its
  89. interest in receiving presence status updates from other HSes, which then
  90. promise to send them when required. Rather than actively polling for the
  91. currentt state all the time, HSes can rely on their relative stability to only
  92. push updates when required.
  93. A Home Server should not rely on the longterm validity of this presence
  94. information, however, as this would not cover such cases as a user's server
  95. crashing and thus failing to inform their peers that users it used to host are
  96. no longer available online. Therefore, each promise of future updates should
  97. carry with a timeout value (whether explicit in the message, or implicit as some
  98. defined default in the protocol), after which the receiving HS should consider
  99. the information potentially stale and request it again.
  100. However, because of the likelyhood that two home servers are exchanging messages
  101. relating to chat traffic in a room common to both of them, the ongoing receipt
  102. of these messages can be taken by each server as an implicit notification that
  103. the sending server is still up and running, and therefore that no status changes
  104. have happened; because if they had the server would have sent them. A second,
  105. larger timeout should be applied to this implicit inference however, to protect
  106. against implementation bugs or other reasons that the presence state cache may
  107. become invalid; eventually the HS should re-enquire the current state of users
  108. and update them with its own.
  109. The following workflows can therefore be used to handle presence updates:
  110. 1 When a user first appears online their HS sends a message to each other HS
  111. containing at least one user to be watched; each message carrying both a
  112. notification of the sender's new online status, and a request to obtain and
  113. watch the target users' presence information. This message implicitly
  114. promises the sending HS will now push updates to the target HSes.
  115. 2 The target HSes then respond a single message each, containing the current
  116. status of the requested user(s). These messages too implicitly promise the
  117. target HSes will themselves push updates to the sending HS.
  118. As these messages arrive at the sending user's HS they can be pushed to the
  119. user's client(s), possibly batched again to ensure not too many small
  120. messages which add extra protocol overheads.
  121. At this point, all the user's clients now have the current presence status
  122. information for this moment in time, and have promised to send each other
  123. updates in future.
  124. 3 The HS maintains two watchdog timers per peer HS it is exchanging presence
  125. information with. The first timer should have a relatively small expiry
  126. (perhaps 1 minute), and the second timer should have a much longer time
  127. (perhaps 1 hour).
  128. 4 Any time any kind of message is received from a peer HS, the short-term
  129. presence timer associated with it is reset.
  130. 5 Whenever either of these timers expires, an HS should push a status reminder
  131. to the target HS whose timer has now expired, and request again from that
  132. server the status of the subscribed users.
  133. 6 On receipt of one of these presence status reminders, an HS can reset both
  134. of its presence watchdog timers.
  135. To avoid bursts of traffic, implementations should attempt to stagger the expiry
  136. of the longer-term watchdog timers for different peer HSes.
  137. When individual users actively change their status (either by explicit requests
  138. from clients, or inferred changes due to idle timers or client timeouts), the HS
  139. should batch up any status changes for some reasonable amount of time (10
  140. seconds to a minute). This allows for reduced protocol overheads in the case of
  141. multiple messages needing to be sent to the same peer HS; as is the likely
  142. scenario in many cases, such as a given human user having multiple user
  143. accounts.
  144. API Requirements
  145. ================
  146. The data model presented here puts the following requirements on the APIs:
  147. Client-Server
  148. -------------
  149. Requests that a client can make to its Home Server
  150. * get/set current presence state
  151. Basic enumeration + ability to set a custom piece of text
  152. * report per-device idle time
  153. After some (configurable?) idle time the device should send a single message
  154. to set the idle duration. The HS can then infer a "start of idle" instant and
  155. use that to keep the device idleness up to date. At some later point the
  156. device can cancel this idleness.
  157. * report per-device type
  158. Inform the server that this device is a "mobile" device, or perhaps some
  159. other to-be-defined category of reduced capability that could be presented to
  160. other users.
  161. * start/stop presence polling for my presence list
  162. It is likely that these messages could be implicitly inferred by other
  163. messages, though having explicit control is always useful.
  164. * get my presence list
  165. [implicit poll start?]
  166. It is possible that the HS doesn't yet have current presence information when
  167. the client requests this. There should be a "don't know" type too.
  168. * add/remove a user to my presence list
  169. Server-Server
  170. -------------
  171. Requests that Home Servers make to others
  172. * request permission to add a user to presence list
  173. * allow/deny a request to add to a presence list
  174. * perform a combined presence state push and subscription request
  175. For each sending user ID, the message contains their new status.
  176. For each receiving user ID, the message should contain an indication on
  177. whether the sending server is also interested in receiving status from that
  178. user; either as an immediate update response now, or as a promise to send
  179. future updates.
  180. Server to Client
  181. ----------------
  182. [[TODO(paul): There also needs to be some way for a user's HS to push status
  183. updates of the presence list to clients, but the general server-client event
  184. model currently lacks a space to do that.]]