You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Expose timeout= on /events to clients
This commit is contained in:
@@ -1999,6 +1999,8 @@ function doInitialSync(client, historyLen, includeArchived) {
|
|||||||
* @param {Boolean} opts.resolveInvitesToProfiles True to do /profile requests
|
* @param {Boolean} opts.resolveInvitesToProfiles True to do /profile requests
|
||||||
* on every invite event if the displayname/avatar_url is not known for this user ID.
|
* on every invite event if the displayname/avatar_url is not known for this user ID.
|
||||||
* Default: false.
|
* Default: false.
|
||||||
|
* @param {Number} opts.pollTimeout The number of milliseconds to wait on /events.
|
||||||
|
* Default: 30000 (30 seconds).
|
||||||
*/
|
*/
|
||||||
MatrixClient.prototype.startClient = function(opts) {
|
MatrixClient.prototype.startClient = function(opts) {
|
||||||
if (this.clientRunning) {
|
if (this.clientRunning) {
|
||||||
@@ -2016,6 +2018,7 @@ MatrixClient.prototype.startClient = function(opts) {
|
|||||||
opts.initialSyncLimit = opts.initialSyncLimit || 8;
|
opts.initialSyncLimit = opts.initialSyncLimit || 8;
|
||||||
opts.includeArchivedRooms = opts.includeArchivedRooms || false;
|
opts.includeArchivedRooms = opts.includeArchivedRooms || false;
|
||||||
opts.resolveInvitesToProfiles = opts.resolveInvitesToProfiles || false;
|
opts.resolveInvitesToProfiles = opts.resolveInvitesToProfiles || false;
|
||||||
|
opts.pollTimeout = opts.pollTimeout || (30 * 1000);
|
||||||
this._config = opts;
|
this._config = opts;
|
||||||
|
|
||||||
if (CRYPTO_ENABLED && this.sessionStore !== null) {
|
if (CRYPTO_ENABLED && this.sessionStore !== null) {
|
||||||
@@ -2054,11 +2057,11 @@ function _pollForEvents(client) {
|
|||||||
discardResult = true;
|
discardResult = true;
|
||||||
console.error("/events request timed out.");
|
console.error("/events request timed out.");
|
||||||
_pollForEvents(client);
|
_pollForEvents(client);
|
||||||
}, 40000);
|
}, client._config.pollTimeout + (20 * 1000)); // 20s buffer
|
||||||
|
|
||||||
client._http.authedRequest(undefined, "GET", "/events", {
|
client._http.authedRequest(undefined, "GET", "/events", {
|
||||||
from: client.store.getSyncToken(),
|
from: client.store.getSyncToken(),
|
||||||
timeout: 30000
|
timeout: client._config.pollTimeout
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
if (discardResult) {
|
if (discardResult) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user