From 85f27543003cc5b7c51427e1ac4429f1db629a9c Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 15 Mar 2016 11:05:05 +0000 Subject: [PATCH] Make the client object be an event emitter rather than a matrixclient to avoid us being tempted to gut wrench stuff directly into the Matrix Client. --- lib/http-api.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/http-api.js b/lib/http-api.js index 819065237..2d9d574c8 100644 --- a/lib/http-api.js +++ b/lib/http-api.js @@ -45,7 +45,7 @@ module.exports.PREFIX_IDENTITY_V1 = "/_matrix/identity/api/v1"; /** * Construct a MatrixHttpApi. * @constructor - * @param {MatrixClient} client The matrix client instance to use. + * @param {EventEmitter} event_emitter The event emitter to use for emitting events * @param {Object} opts The options to use for this HTTP API. * @param {string} opts.baseUrl Required. The base client-server URL e.g. * 'http://localhost:8008'. @@ -61,10 +61,10 @@ module.exports.PREFIX_IDENTITY_V1 = "/_matrix/identity/api/v1"; * @param {Object} opts.extraParams Optional. Extra query parameters to send on * requests. */ -module.exports.MatrixHttpApi = function MatrixHttpApi(client, opts) { +module.exports.MatrixHttpApi = function MatrixHttpApi(event_emitter, opts) { utils.checkObjectHasKeys(opts, ["baseUrl", "request", "prefix"]); opts.onlyData = opts.onlyData || false; - this.client = client; + this.event_emitter = event_emitter; this.opts = opts; this.uploads = []; }; @@ -275,7 +275,7 @@ module.exports.MatrixHttpApi.prototype = { callback, method, path, queryParams, data, localTimeoutMs ).catch(function(err) { if (err.errcode == 'M_UNKNOWN_TOKEN') { - self.client.emit("Session.logged_out"); + self.event_emitter.emit("Session.logged_out"); } throw err; });