From 3b21998d968415c279a80fc05df697271ce15ce9 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 3 Nov 2015 10:18:56 +0000 Subject: [PATCH] Expose timeout= on /events to clients --- lib/client.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index a0e513a73..bccbe38e8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1999,6 +1999,8 @@ function doInitialSync(client, historyLen, includeArchived) { * @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. * Default: false. + * @param {Number} opts.pollTimeout The number of milliseconds to wait on /events. + * Default: 30000 (30 seconds). */ MatrixClient.prototype.startClient = function(opts) { if (this.clientRunning) { @@ -2016,6 +2018,7 @@ MatrixClient.prototype.startClient = function(opts) { opts.initialSyncLimit = opts.initialSyncLimit || 8; opts.includeArchivedRooms = opts.includeArchivedRooms || false; opts.resolveInvitesToProfiles = opts.resolveInvitesToProfiles || false; + opts.pollTimeout = opts.pollTimeout || (30 * 1000); this._config = opts; if (CRYPTO_ENABLED && this.sessionStore !== null) { @@ -2054,11 +2057,11 @@ function _pollForEvents(client) { discardResult = true; console.error("/events request timed out."); _pollForEvents(client); - }, 40000); + }, client._config.pollTimeout + (20 * 1000)); // 20s buffer client._http.authedRequest(undefined, "GET", "/events", { from: client.store.getSyncToken(), - timeout: 30000 + timeout: client._config.pollTimeout }).done(function(data) { if (discardResult) { return;