@@ -92,6 +92,19 @@ class Client extends MatrixApi {
92
92
93
93
ShareKeysWith shareKeysWith;
94
94
95
+ /// Implement your https://spec.matrix.org/v1.9/client-server-api/#soft-logout
96
+ /// logic here.
97
+ /// Set this to [Client.refreshAccessToken] for the easiest way to handle the
98
+ /// most common reason for soft logouts.
99
+ ///
100
+ /// Please ensure to also provide a [MatrixRefreshTokenClient] as
101
+ /// [httpClient] in order to handle soft logout on non-sync calls.
102
+ ///
103
+ /// You may want to wrap the default
104
+ /// [Client.refreshAccessToken] implementation with retry logic in case
105
+ /// you run into situations where the token refresh may fail due to bad
106
+ /// network connectivity.
107
+ /// You can also perform a new login here by passing the existing deviceId.
95
108
Future <void > Function (Client client)? onSoftLogout;
96
109
97
110
DateTime ? get accessTokenExpiresAt => _accessTokenExpiresAt;
@@ -151,13 +164,19 @@ class Client extends MatrixApi {
151
164
)? customImageResizer;
152
165
153
166
/// Create a client
154
- /// [clientName] = unique identifier of this client
167
+ ///
168
+ /// [clientName] : unique identifier of this client
169
+ ///
155
170
/// [databaseBuilder] : A function that creates the database instance, that will be used.
171
+ ///
156
172
/// [legacyDatabaseBuilder] : Use this for your old database implementation to perform an automatic migration
173
+ ///
157
174
/// [databaseDestroyer] : A function that can be used to destroy a database instance, for example by deleting files from disk.
175
+ ///
158
176
/// [verificationMethods] : A set of all the verification methods this client can handle. Includes:
159
177
/// KeyVerificationMethod.numbers: Compare numbers. Most basic, should be supported
160
178
/// KeyVerificationMethod.emoji: Compare emojis
179
+ ///
161
180
/// [importantStateEvents] : A set of all the important state events to load when the client connects.
162
181
/// To speed up performance only a set of state events is loaded on startup, those that are
163
182
/// needed to display a room list. All the remaining state events are automatically post-loaded
@@ -171,24 +190,43 @@ class Client extends MatrixApi {
171
190
/// - m.room.canonical_alias
172
191
/// - m.room.tombstone
173
192
/// - *some* m.room.member events, where needed
193
+ ///
194
+ /// [httpClient] : The inner [Client] used to dispatch any HTTP requests
195
+ /// performed by the SDK. The [Client] you pass here will by default be
196
+ /// wrapped with a [FixedTimeoutHttpClient] with the specified
197
+ /// [defaultNetworkRequestTimeout]. In case you do not wish this wrapper,
198
+ /// you can later override the [httpClient] by using the
199
+ /// [Client.httpClient] setter.
200
+ ///
201
+ /// In case your homeserver supports refresh tokens, please ensure you
202
+ /// provide a [MatrixRefreshTokenClient] .
203
+ ///
174
204
/// [roomPreviewLastEvents] : The event types that should be used to calculate the last event
175
205
/// in a room for the room list.
206
+ ///
176
207
/// Set [requestHistoryOnLimitedTimeline] to controll the automatic behaviour if the client
177
208
/// receives a limited timeline flag for a room.
209
+ ///
178
210
/// If [mxidLocalPartFallback] is true, then the local part of the mxid will be shown
179
211
/// if there is no other displayname available. If not then this will return "Unknown user".
212
+ ///
180
213
/// If [formatLocalpart] is true, then the localpart of an mxid will
181
214
/// be formatted in the way, that all "_" characters are becomming white spaces and
182
215
/// the first character of each word becomes uppercase.
216
+ ///
183
217
/// If your client supports more login types like login with token or SSO, then add this to
184
218
/// [supportedLoginTypes] . Set a custom [syncFilter] if you like. By default the app
185
219
/// will use lazy_load_members.
220
+ ///
186
221
/// Set [nativeImplementations] to [NativeImplementationsIsolate] in order to
187
222
/// enable the SDK to compute some code in background.
223
+ ///
188
224
/// Set [timelineEventTimeout] to the preferred time the Client should retry
189
225
/// sending events on connection problems or to `Duration.zero` to disable it.
226
+ ///
190
227
/// Set [customImageResizer] to your own implementation for a more advanced
191
228
/// and faster image resizing experience.
229
+ ///
192
230
/// Set [enableDehydratedDevices] to enable experimental support for enabling MSC3814 dehydrated devices.
193
231
Client (
194
232
this .clientName, {
@@ -222,12 +260,6 @@ class Client extends MatrixApi {
222
260
this .shareKeysWith = ShareKeysWith .crossVerifiedIfEnabled,
223
261
this .enableDehydratedDevices = false ,
224
262
this .receiptsPublicByDefault = true ,
225
-
226
- /// Implement your https://spec.matrix.org/v1.9/client-server-api/#soft-logout
227
- /// logic here.
228
- /// Set this to `refreshAccessToken()` for the easiest way to handle the
229
- /// most common reason for soft logouts.
230
- /// You can also perform a new login here by passing the existing deviceId.
231
263
this .onSoftLogout,
232
264
233
265
/// Experimental feature which allows to send a custom refresh token
@@ -2438,6 +2470,7 @@ class Client extends MatrixApi {
2438
2470
),
2439
2471
);
2440
2472
if (e.error == MatrixError .M_UNKNOWN_TOKEN ) {
2473
+ // due to race conditions via QUIC, still handle soft_logout here
2441
2474
if (e.raw.tryGet <bool >('soft_logout' ) == true ) {
2442
2475
Logs ().w (
2443
2476
'The user has been soft logged out! Calling client.onSoftLogout() if present.' ,
0 commit comments