diff --git a/src/common/lib/client/realtimechannel.ts b/src/common/lib/client/realtimechannel.ts index 898377dded..3200088bb6 100644 --- a/src/common/lib/client/realtimechannel.ts +++ b/src/common/lib/client/realtimechannel.ts @@ -1,7 +1,7 @@ import ProtocolMessage from '../types/protocolmessage'; import EventEmitter from '../util/eventemitter'; import * as Utils from '../util/utils'; -import Channel from './channel'; +import RestChannel from './restchannel'; import Logger from '../util/logger'; import RealtimePresence from './realtimepresence'; import Message, { CipherOptions } from '../types/message'; @@ -48,7 +48,7 @@ function validateChannelOptions(options?: API.Types.ChannelOptions) { } } -class RealtimeChannel extends Channel { +class RealtimeChannel extends RestChannel { realtime: BaseRealtime; private _realtimePresence: RealtimePresence | null; get presence(): RealtimePresence { @@ -156,7 +156,7 @@ class RealtimeChannel extends Channel { _callback(err); return; } - Channel.prototype.setOptions.call(this, options); + RestChannel.prototype.setOptions.call(this, options); if (this._decodingContext) this._decodingContext.channelOptions = this.channelOptions; if (this._shouldReattachToSetOptions(options)) { /* This does not just do _attach(true, null, callback) because that would put us @@ -900,7 +900,7 @@ class RealtimeChannel extends Channel { params.from_serial = this.properties.attachSerial; } - Channel.prototype._history.call(this, params, callback); + RestChannel.prototype._history.call(this, params, callback); } as any; whenState = ((state: string, listener: ErrCallback) => { diff --git a/src/common/lib/client/realtimepresence.ts b/src/common/lib/client/realtimepresence.ts index 5d5e84c346..7fc5a63c47 100644 --- a/src/common/lib/client/realtimepresence.ts +++ b/src/common/lib/client/realtimepresence.ts @@ -1,5 +1,5 @@ import * as Utils from '../util/utils'; -import Presence from './presence'; +import RestPresence from './restpresence'; import EventEmitter from '../util/eventemitter'; import Logger from '../util/logger'; import PresenceMessage, { fromValues as presenceMessageFromValues } from '../types/presencemessage'; @@ -78,7 +78,7 @@ function newerThan(item: PresenceMessage, existing: PresenceMessage) { } } -class RealtimePresence extends Presence { +class RealtimePresence extends RestPresence { channel: RealtimeChannel; pendingPresence: { presence: PresenceMessage; callback: ErrCallback }[]; syncComplete: boolean; @@ -319,7 +319,7 @@ class RealtimePresence extends Presence { } } - Presence.prototype._history.call(this, params, callback); + RestPresence.prototype._history.call(this, params, callback); } setPresence(presenceSet: PresenceMessage[], isSync: boolean, syncChannelSerial?: string): void { diff --git a/src/common/lib/client/rest.ts b/src/common/lib/client/rest.ts index 4a5f60d66f..f1fb22badd 100644 --- a/src/common/lib/client/rest.ts +++ b/src/common/lib/client/rest.ts @@ -3,7 +3,7 @@ import Logger, { LoggerOptions } from '../util/logger'; import Defaults from '../util/defaults'; import Push from './push'; import PaginatedResource, { HttpPaginatedResponse, PaginatedResult } from './paginatedresource'; -import Channel from './channel'; +import RestChannel from './restchannel'; import ErrorInfo from '../types/errorinfo'; import Stats from '../types/stats'; import HttpMethods from '../../constants/HttpMethods'; @@ -324,7 +324,7 @@ export class Rest { class Channels { client: BaseClient; - all: Record; + all: Record; constructor(client: BaseClient) { this.client = client; @@ -335,7 +335,7 @@ class Channels { name = String(name); let channel = this.all[name]; if (!channel) { - this.all[name] = channel = new Channel(this.client, name, channelOptions); + this.all[name] = channel = new RestChannel(this.client, name, channelOptions); } else if (channelOptions) { channel.setOptions(channelOptions); } diff --git a/src/common/lib/client/channel.ts b/src/common/lib/client/restchannel.ts similarity index 94% rename from src/common/lib/client/channel.ts rename to src/common/lib/client/restchannel.ts index 2922de7adb..b88fa807b9 100644 --- a/src/common/lib/client/channel.ts +++ b/src/common/lib/client/restchannel.ts @@ -1,7 +1,7 @@ import * as Utils from '../util/utils'; import EventEmitter from '../util/eventemitter'; import Logger from '../util/logger'; -import Presence from './presence'; +import RestPresence from './restpresence'; import Message, { CipherOptions } from '../types/message'; import ErrorInfo from '../types/errorinfo'; import PaginatedResource, { PaginatedResult } from './paginatedresource'; @@ -46,23 +46,23 @@ function normaliseChannelOptions(Crypto: IUntypedCryptoStatic | null, options?: return channelOptions; } -class Channel extends EventEmitter { +class RestChannel extends EventEmitter { client: BaseClient; name: string; basePath: string; - private _presence: Presence; - get presence(): Presence { + private _presence: RestPresence; + get presence(): RestPresence { return this._presence; } channelOptions: ChannelOptions; constructor(client: BaseClient, name: string, channelOptions?: ChannelOptions) { super(); - Logger.logAction(Logger.LOG_MINOR, 'Channel()', 'started; name = ' + name); + Logger.logAction(Logger.LOG_MINOR, 'RestChannel()', 'started; name = ' + name); this.client = client; this.name = name; this.basePath = '/channels/' + encodeURIComponent(name); - this._presence = new Presence(this); + this._presence = new RestPresence(this); this.channelOptions = normaliseChannelOptions(client._Crypto ?? null, channelOptions); } @@ -74,7 +74,7 @@ class Channel extends EventEmitter { params: RestHistoryParams | null, callback: PaginatedResultCallback ): Promise> | void { - Logger.logAction(Logger.LOG_MICRO, 'Channel.history()', 'channel = ' + this.name); + Logger.logAction(Logger.LOG_MICRO, 'RestChannel.history()', 'channel = ' + this.name); /* params and callback are optional; see if params contains the callback */ if (callback === undefined) { if (typeof params == 'function') { @@ -200,4 +200,4 @@ class Channel extends EventEmitter { } } -export default Channel; +export default RestChannel; diff --git a/src/common/lib/client/presence.ts b/src/common/lib/client/restpresence.ts similarity index 89% rename from src/common/lib/client/presence.ts rename to src/common/lib/client/restpresence.ts index 8acbed68bf..7a4f73960e 100644 --- a/src/common/lib/client/presence.ts +++ b/src/common/lib/client/restpresence.ts @@ -5,22 +5,22 @@ import PaginatedResource, { PaginatedResult } from './paginatedresource'; import PresenceMessage from '../types/presencemessage'; import { CipherOptions } from '../types/message'; import { PaginatedResultCallback } from '../../types/utils'; -import Channel from './channel'; +import RestChannel from './restchannel'; import RealtimeChannel from './realtimechannel'; import Defaults from '../util/defaults'; -class Presence extends EventEmitter { - channel: RealtimeChannel | Channel; +class RestPresence extends EventEmitter { + channel: RealtimeChannel | RestChannel; basePath: string; - constructor(channel: RealtimeChannel | Channel) { + constructor(channel: RealtimeChannel | RestChannel) { super(); this.channel = channel; this.basePath = channel.basePath + '/presence'; } get(params: any, callback: PaginatedResultCallback): void | Promise { - Logger.logAction(Logger.LOG_MICRO, 'Presence.get()', 'channel = ' + this.channel.name); + Logger.logAction(Logger.LOG_MICRO, 'RestPresence.get()', 'channel = ' + this.channel.name); /* params and callback are optional; see if params contains the callback */ if (callback === undefined) { if (typeof params == 'function') { @@ -52,7 +52,7 @@ class Presence extends EventEmitter { params: any, callback: PaginatedResultCallback ): void | Promise> { - Logger.logAction(Logger.LOG_MICRO, 'Presence.history()', 'channel = ' + this.channel.name); + Logger.logAction(Logger.LOG_MICRO, 'RestPresence.history()', 'channel = ' + this.channel.name); return this._history(params, callback); } @@ -93,4 +93,4 @@ class Presence extends EventEmitter { } } -export default Presence; +export default RestPresence;