@@ -1273,32 +1273,51 @@ Lazy-loading room members
1273
1273
1274
1274
Membership events often take significant resources for clients to track. In an
1275
1275
effort to reduce the number of resources used, clients can enable "lazy-loading"
1276
- for room members. By doing this, servers will only ever send membership events
1276
+ for room members. By doing this, servers will attempt to only send membership events
1277
1277
which are relevant to the client.
1278
1278
1279
- In terms of filters, this means enabling ``lazy_load_members `` on a ``RoomEventFilter ``
1280
- (or a ``StateFilter `` in the case of ``/sync `` only). When enabled, lazy-loading
1281
- aware endpoints (see below) will only include membership events for the ``sender ``
1282
- of events being included in the response. For example, if a client makes a ``/sync ``
1283
- request with lazy-loading enabled, the server will only return membership events
1284
- for the ``sender `` of events in the timeline, not all members of a room.
1285
-
1286
- Repeated calls to lazy-loading aware endpoints will result in redundant membership
1287
- events being excluded by default. Clients often track which membership events they
1288
- already have, therefore making the extra information not as useful to the client.
1289
- Clients can always request redundant membership events by setting ``include_redundant_members ``
1290
- to true in the filter.
1291
-
1292
- Servers should be cautious about which events they consider redundant. Membership
1293
- events can change over time, and should be included as relevant to maintain the
1294
- historical record. Likewise, clients should be cautious about treating an older event
1295
- as the current membership event for a user.
1296
-
1297
- .. Note ::
1298
- Repeated calls using the same filter to *any * lazy-loading aware endpoint may
1299
- result in redundant membership events being excluded from future calls. For example, a
1300
- request to ``/sync `` followed by a request to ``/messages `` may result in a
1301
- future call to ``/sync `` excluding membership events returned by the ``/messages `` call.
1279
+ It is important to understand that lazy-loading is not intended to be a
1280
+ perfect optimisation, and that it may not be practical for the server to
1281
+ calculate precisely which membership events are relevant to the client. As a
1282
+ result, it is valid for the server to send redundant membership events to the
1283
+ client to ease implementation, although such redundancy should be minimised
1284
+ where possible to conserve bandwidth.
1285
+
1286
+ In terms of filters, lazy-loading is enabled by enabling ``lazy_load_members ``
1287
+ on a ``RoomEventFilter `` (or a ``StateFilter `` in the case of ``/sync `` only).
1288
+ When enabled, lazy-loading aware endpoints (see below) will only include
1289
+ membership events for the ``sender `` of events being included in the response.
1290
+ For example, if a client makes a ``/sync `` request with lazy-loading enabled,
1291
+ the server will only return membership events for the ``sender `` of events in
1292
+ the timeline, not all members of a room.
1293
+
1294
+ When processing a sequence of events (e.g. by looping on ``/sync `` or
1295
+ paginating ``/messages ``), it is common for blocks of events in the sequence
1296
+ to share a similar set of senders. Rather than responses in the sequence
1297
+ sending duplicate membership events for these senders to the client, the
1298
+ server MAY assume that clients will remember membership events they have
1299
+ already been sent, and choose to skip sending membership events for members
1300
+ whose membership has not changed. These are called 'redundant membership
1301
+ events'. Clients may request that redundant membership events are always
1302
+ included in responses by setting ``include_redundant_members `` to true in the
1303
+ filter.
1304
+
1305
+ The expected pattern for using lazy-loading is currently:
1306
+
1307
+ * Client performs an initial /sync with lazy-loading enabled, and receives
1308
+ only the membership events which relate to the senders of the events it
1309
+ receives.
1310
+ * Clients which support display-name tab-completion or other operations which
1311
+ require rapid access to all members in a room should call /members for the
1312
+ currently selected room, with an ``?at `` parameter set to the /sync
1313
+ response's from token. The member list for the room is then maintained by
1314
+ the state in subsequent incremental /sync responses.
1315
+ * Clients which do not support tab-completion may instead pull in profiles for
1316
+ arbitrary users (e.g. read receipts, typing notifications) on demand by
1317
+ querying the room state or ``/profile ``.
1318
+
1319
+ .. TODO-spec
1320
+ This implies that GET /state should also take an ``?at`` param
1302
1321
1303
1322
The current endpoints which support lazy-loading room members are:
1304
1323
0 commit comments