From 7bde747095225baddbd19bd23f8b87590ce691ec Mon Sep 17 00:00:00 2001 From: Jonathan Casarrubias Date: Fri, 18 Aug 2017 09:32:25 -0500 Subject: [PATCH] Release 2.1.0-rc.13.5 :rocket: - Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/47?closed=1 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/482 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/481 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/480 - Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/475 --- CHANGELOG.md | 9 +++ lib/angular2/index.js | 38 ++++++++-- lib/angular2/shared/models/flref.ts | 70 ++++++++++++------- lib/angular2/shared/sockets/connections.ts | 15 ++++ package.json | 2 +- .../src/app/shared/sdk/models/FireLoopRef.ts | 70 ++++++++++++------- .../app/shared/sdk/services/core/real.time.ts | 1 - .../app/shared/sdk/services/custom/Account.ts | 3 - .../app/shared/sdk/services/custom/Storage.ts | 4 -- .../app/shared/sdk/services/custom/User.ts | 3 - .../shared/sdk/sockets/socket.connections.ts | 15 ++++ 11 files changed, 161 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f44aa6a..09d318c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ This file is created to keep history of the LoopBack SDK Builder, it does not consider or keeps any history of its parent module `loopback-sdk-angular` +## Release 2.1.0-rc.13.5 + +- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/47?closed=1 + +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/482 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/481 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/480 +- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/475 + ## Release 2.1.0-rc.13.4 - Replaces Release 2.1.0-rc.13.3 diff --git a/lib/angular2/index.js b/lib/angular2/index.js index 9a9b00ef..e9428b8e 100644 --- a/lib/angular2/index.js +++ b/lib/angular2/index.js @@ -776,6 +776,31 @@ module.exports = function generate(ctx) { function paramIsContext(param) { return (typeof param.http !== 'undefined' && typeof param.http.source !== 'undefined' && param.http.source === 'context'); } + /** + * @method paramIsBody + * @description + * Testing if the param is a http.body or form + */ + function paramIsBody(param) { + return (typeof param.http !== 'undefined' && typeof param.http.source !== 'undefined' && (param.http.source == 'body' || param.http.source == 'form')); + } + /** + * @method paramIsQuery + * @description + * Testing if the param is a http.query or form + */ + function paramIsQuery(param) { + return ( + ( + typeof param.http === 'undefined' && // Query is default, if http is not defined we treat it as query param + (param.arg && !param.arg.match(/(^id$|fk|^file$|container)/)) // But only if it is not id, fk, file or container + ) + || + ( + typeof param.http !== 'undefined' && typeof param.http.source !== 'undefined' && param.http.source == 'query' + ) + ); + } /** * @method buildPostBody * @description @@ -786,11 +811,11 @@ module.exports = function generate(ctx) { if (Array.isArray(postData)) { postData = postData.filter(param => { // Filter out route params and function params - if (paramIsRoute(param) || paramIsFunction(param)) { + if (paramIsRoute(param) || paramIsFunction(param) || paramIsContext(param) || paramIsQuery(param)) { return false } // Make sure the param is body or form data - return param.http && (param.http.source == 'body' || param.http.source == 'form') + return paramIsBody(param); }) if (postData.length > 0) { output.push(''); @@ -826,11 +851,11 @@ module.exports = function generate(ctx) { // filter params that should not go over url query string urlParams = urlParams.filter(param => { // Filter out route params and function params - if (paramIsRoute(param) || paramIsFunction(param) || paramIsContext(param)) { + if (paramIsRoute(param) || paramIsFunction(param) || paramIsContext(param) || paramIsBody(param)) { return false } // Filter out body params - return (!param.http || param.http.source != 'body') + return paramIsQuery(param); }); if (model.isUser && methodName === 'logout') output.push(` _urlParams.access_token = this.auth.getAccessTokenId();`); @@ -850,7 +875,10 @@ module.exports = function generate(ctx) { let output = []; if (routeParams) { routeParams = routeParams.filter((param) => { - return paramIsRoute(param) && !paramIsFunction(param) + if (paramIsQuery(param) || paramIsFunction(param) || paramIsContext(param) || paramIsBody(param)) { + return false + } + return paramIsRoute(param) }); if (routeParams.length > 0) { output.push(''); diff --git a/lib/angular2/shared/models/flref.ts b/lib/angular2/shared/models/flref.ts index 42b2c0b3..4bfd4b28 100644 --- a/lib/angular2/shared/models/flref.ts +++ b/lib/angular2/shared/models/flref.ts @@ -18,6 +18,8 @@ export class FireLoopRef { private instance: any; // Model Childs private childs: any = {}; + // Disposable Events + private disposable: { [key: string]: any } = {}; /** * @method constructor * @param {any} model The model we want to create a reference @@ -37,8 +39,8 @@ export class FireLoopRef { private relationship: string = null ) { this.socket.emit( - `Subscribe.${ !parent ? model.getModelName() : parent.model.getModelName() }`, - { id : this.id, scope: model.getModelName(), relationship: relationship } + `Subscribe.${!parent ? model.getModelName() : parent.model.getModelName()}`, + { id: this.id, scope: model.getModelName(), relationship: relationship } ); return this; } @@ -54,9 +56,13 @@ export class FireLoopRef { * } **/ public dispose(): void { - this.operation('dispose', {}) - .subscribe() - .unsubscribe(); + const subscription = this.operation('dispose', {}).subscribe(() => { + Object.keys(this.disposable).forEach((channel: string) => { + this.socket.removeListener(channel, this.disposable[channel]); + this.socket.removeAllListeners(channel); + }); + subscription.unsubscribe(); + }); } /** * @method upsert @@ -116,9 +122,9 @@ export class FireLoopRef { public onRemote(method: string): Observable { let event: string = 'remote'; if (!this.relationship) { - event = `${ this.model.getModelName() }.${event}`; + event = `${this.model.getModelName()}.${event}`; } else { - event = `${ this.parent.model.getModelName() }.${ this.relationship }.${event}`; + event = `${this.parent.model.getModelName()}.${this.relationship}.${event}`; } return this.broadcasts(event, {}); } @@ -141,10 +147,10 @@ export class FireLoopRef { } let request: any; if (!this.relationship) { - event = `${ this.model.getModelName() }.${event}`; + event = `${this.model.getModelName()}.${event}`; request = { filter }; } else { - event = `${ this.parent.model.getModelName() }.${ this.relationship }.${event}`; + event = `${this.parent.model.getModelName()}.${this.relationship}.${event}`; request = { filter, parent: this.parent.instance }; } if (event.match(/(value|change|stats)/)) { @@ -182,7 +188,7 @@ export class FireLoopRef { **/ public make(instance: any): FireLoopRef { let reference: FireLoopRef = new FireLoopRef(this.model, this.socket); - reference.instance = instance; + reference.instance = instance; return reference; } /** @@ -200,15 +206,15 @@ export class FireLoopRef { let settings: any = this.model.getModelDefinition().relations[relationship]; // Verify the relationship actually exists if (!settings) { - throw new Error(`Invalid model relationship ${ this.model.getModelName() } <-> ${ relationship }, verify your model settings.`); + throw new Error(`Invalid model relationship ${this.model.getModelName()} <-> ${relationship}, verify your model settings.`); } // Verify if the relationship model is public if (settings.model === '') { - throw new Error(`Relationship model is private, cam't use ${ relationship } unless you set your model as public.`); + throw new Error(`Relationship model is private, cam't use ${relationship} unless you set your model as public.`); } // Lets get a model reference and add a reference for all of the models - let model: any = this.model.models.get(settings.model); - model.models = this.model.models; + let model: any = this.model.models.get(settings.model); + model.models = this.model.models; // If everything goes well, we will store a child reference and return it. this.childs[relationship] = new FireLoopRef(model, this.socket, this, relationship); return this.childs[relationship]; @@ -224,8 +230,8 @@ export class FireLoopRef { private pull(event: string, request: any): Observable { let sbj: Subject = new Subject(); let that: FireLoopRef = this; - let nowEvent: any = `${event}.pull.requested.${ this.id }`; - this.socket.emit(`${event}.pull.request.${ this.id }`, request); + let nowEvent: any = `${event}.pull.requested.${this.id}`; + this.socket.emit(`${event}.pull.request.${this.id}`, request); function pullNow(data: any) { if (that.socket.removeListener) { that.socket.removeListener(nowEvent, pullNow); @@ -246,12 +252,21 @@ export class FireLoopRef { **/ private broadcasts(event: string, request: any): Observable { let sbj: Subject = new Subject(); - this.socket.on( - `${event}.broadcast.announce.${ this.id }`, - (res: T) => - this.socket.emit(`${event}.broadcast.request.${ this.id }`, request) - ); - this.socket.on(`${ event }.broadcast.${ this.id }`, (data: any) => sbj.next(data)); + let channels: { announce: string, broadcast: string } = { + announce: `${event}.broadcast.announce.${this.id}`, + broadcast: `${event}.broadcast.${this.id}` + }; + let that = this; + // Announces Handler + this.disposable[channels.announce] = function (res: T) { + that.socket.emit(`${event}.broadcast.request.${that.id}`, request) + }; + // Broadcasts Handler + this.disposable[channels.broadcast] = function (data: any) { + sbj.next(data); + }; + this.socket.on(channels.announce, this.disposable[channels.announce]); + this.socket.on(channels.broadcast, this.disposable[channels.broadcast]); return sbj.asObservable(); } /** @@ -264,9 +279,9 @@ export class FireLoopRef { **/ private operation(event: string, data: any): Observable { if (!this.relationship) { - event = `${ this.model.getModelName() }.${event}.${ this.id }`; + event = `${this.model.getModelName()}.${event}.${this.id}`; } else { - event = `${ this.parent.model.getModelName() }.${ this.relationship }.${ event }.${ this.id }`; + event = `${this.parent.model.getModelName()}.${this.relationship}.${event}.${this.id}`; } let subject: Subject = new Subject(); let config: { data: any, parent: any } = { @@ -276,9 +291,9 @@ export class FireLoopRef { this.socket.emit(event, config); let resultEvent: string = ''; if (!this.relationship) { - resultEvent = `${ this.model.getModelName()}.value.result.${ this.id }`; + resultEvent = `${this.model.getModelName()}.value.result.${this.id}`; } else { - resultEvent = `${ this.parent.model.getModelName() }.${ this.relationship }.value.result.${ this.id }`; + resultEvent = `${this.parent.model.getModelName()}.${this.relationship}.value.result.${this.id}`; } this.socket.on(resultEvent, (res: any) => { if (res.error) { @@ -287,6 +302,9 @@ export class FireLoopRef { subject.next(res); } }); + if (event.match('dispose')) { + setTimeout(() => subject.next()); + } // This event listener will be wiped within socket.connections this.socket.sharedObservables.sharedOnDisconnect.subscribe(() => subject.complete()); return subject.asObservable().catch((error: any) => Observable.throw(error)); diff --git a/lib/angular2/shared/sockets/connections.ts b/lib/angular2/shared/sockets/connections.ts index 3ca1f106..1608b45d 100644 --- a/lib/angular2/shared/sockets/connections.ts +++ b/lib/angular2/shared/sockets/connections.ts @@ -162,6 +162,21 @@ export class SocketConnection { this.socket.off(event, handler); } } + /** + * @method removeAllListeners + * @param {string} event Event name + * @param {Function} handler Event listener handler + * @return {void} + * @description + * This method will wrap the original "on" method and run it within the Angular Zone + * Note: off is being used since the nativescript socket io client does not provide + * removeListener method, but only provides with off which is provided in any platform. + **/ + public removeAllListeners(event: string): void { + if (typeof this.socket.removeAllListeners === 'function') { + this.socket.removeAllListeners(event); + } + } /** * @method disconnect * @return {void} diff --git a/package.json b/package.json index 7325e10c..7174c29c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mean-expert/loopback-sdk-builder", - "version": "2.1.0-rc.13.4", + "version": "2.1.0-rc.13.5", "description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack", "bin": { "lb-sdk": "bin/lb-sdk" diff --git a/tests/ng2web/src/app/shared/sdk/models/FireLoopRef.ts b/tests/ng2web/src/app/shared/sdk/models/FireLoopRef.ts index 42b2c0b3..4bfd4b28 100644 --- a/tests/ng2web/src/app/shared/sdk/models/FireLoopRef.ts +++ b/tests/ng2web/src/app/shared/sdk/models/FireLoopRef.ts @@ -18,6 +18,8 @@ export class FireLoopRef { private instance: any; // Model Childs private childs: any = {}; + // Disposable Events + private disposable: { [key: string]: any } = {}; /** * @method constructor * @param {any} model The model we want to create a reference @@ -37,8 +39,8 @@ export class FireLoopRef { private relationship: string = null ) { this.socket.emit( - `Subscribe.${ !parent ? model.getModelName() : parent.model.getModelName() }`, - { id : this.id, scope: model.getModelName(), relationship: relationship } + `Subscribe.${!parent ? model.getModelName() : parent.model.getModelName()}`, + { id: this.id, scope: model.getModelName(), relationship: relationship } ); return this; } @@ -54,9 +56,13 @@ export class FireLoopRef { * } **/ public dispose(): void { - this.operation('dispose', {}) - .subscribe() - .unsubscribe(); + const subscription = this.operation('dispose', {}).subscribe(() => { + Object.keys(this.disposable).forEach((channel: string) => { + this.socket.removeListener(channel, this.disposable[channel]); + this.socket.removeAllListeners(channel); + }); + subscription.unsubscribe(); + }); } /** * @method upsert @@ -116,9 +122,9 @@ export class FireLoopRef { public onRemote(method: string): Observable { let event: string = 'remote'; if (!this.relationship) { - event = `${ this.model.getModelName() }.${event}`; + event = `${this.model.getModelName()}.${event}`; } else { - event = `${ this.parent.model.getModelName() }.${ this.relationship }.${event}`; + event = `${this.parent.model.getModelName()}.${this.relationship}.${event}`; } return this.broadcasts(event, {}); } @@ -141,10 +147,10 @@ export class FireLoopRef { } let request: any; if (!this.relationship) { - event = `${ this.model.getModelName() }.${event}`; + event = `${this.model.getModelName()}.${event}`; request = { filter }; } else { - event = `${ this.parent.model.getModelName() }.${ this.relationship }.${event}`; + event = `${this.parent.model.getModelName()}.${this.relationship}.${event}`; request = { filter, parent: this.parent.instance }; } if (event.match(/(value|change|stats)/)) { @@ -182,7 +188,7 @@ export class FireLoopRef { **/ public make(instance: any): FireLoopRef { let reference: FireLoopRef = new FireLoopRef(this.model, this.socket); - reference.instance = instance; + reference.instance = instance; return reference; } /** @@ -200,15 +206,15 @@ export class FireLoopRef { let settings: any = this.model.getModelDefinition().relations[relationship]; // Verify the relationship actually exists if (!settings) { - throw new Error(`Invalid model relationship ${ this.model.getModelName() } <-> ${ relationship }, verify your model settings.`); + throw new Error(`Invalid model relationship ${this.model.getModelName()} <-> ${relationship}, verify your model settings.`); } // Verify if the relationship model is public if (settings.model === '') { - throw new Error(`Relationship model is private, cam't use ${ relationship } unless you set your model as public.`); + throw new Error(`Relationship model is private, cam't use ${relationship} unless you set your model as public.`); } // Lets get a model reference and add a reference for all of the models - let model: any = this.model.models.get(settings.model); - model.models = this.model.models; + let model: any = this.model.models.get(settings.model); + model.models = this.model.models; // If everything goes well, we will store a child reference and return it. this.childs[relationship] = new FireLoopRef(model, this.socket, this, relationship); return this.childs[relationship]; @@ -224,8 +230,8 @@ export class FireLoopRef { private pull(event: string, request: any): Observable { let sbj: Subject = new Subject(); let that: FireLoopRef = this; - let nowEvent: any = `${event}.pull.requested.${ this.id }`; - this.socket.emit(`${event}.pull.request.${ this.id }`, request); + let nowEvent: any = `${event}.pull.requested.${this.id}`; + this.socket.emit(`${event}.pull.request.${this.id}`, request); function pullNow(data: any) { if (that.socket.removeListener) { that.socket.removeListener(nowEvent, pullNow); @@ -246,12 +252,21 @@ export class FireLoopRef { **/ private broadcasts(event: string, request: any): Observable { let sbj: Subject = new Subject(); - this.socket.on( - `${event}.broadcast.announce.${ this.id }`, - (res: T) => - this.socket.emit(`${event}.broadcast.request.${ this.id }`, request) - ); - this.socket.on(`${ event }.broadcast.${ this.id }`, (data: any) => sbj.next(data)); + let channels: { announce: string, broadcast: string } = { + announce: `${event}.broadcast.announce.${this.id}`, + broadcast: `${event}.broadcast.${this.id}` + }; + let that = this; + // Announces Handler + this.disposable[channels.announce] = function (res: T) { + that.socket.emit(`${event}.broadcast.request.${that.id}`, request) + }; + // Broadcasts Handler + this.disposable[channels.broadcast] = function (data: any) { + sbj.next(data); + }; + this.socket.on(channels.announce, this.disposable[channels.announce]); + this.socket.on(channels.broadcast, this.disposable[channels.broadcast]); return sbj.asObservable(); } /** @@ -264,9 +279,9 @@ export class FireLoopRef { **/ private operation(event: string, data: any): Observable { if (!this.relationship) { - event = `${ this.model.getModelName() }.${event}.${ this.id }`; + event = `${this.model.getModelName()}.${event}.${this.id}`; } else { - event = `${ this.parent.model.getModelName() }.${ this.relationship }.${ event }.${ this.id }`; + event = `${this.parent.model.getModelName()}.${this.relationship}.${event}.${this.id}`; } let subject: Subject = new Subject(); let config: { data: any, parent: any } = { @@ -276,9 +291,9 @@ export class FireLoopRef { this.socket.emit(event, config); let resultEvent: string = ''; if (!this.relationship) { - resultEvent = `${ this.model.getModelName()}.value.result.${ this.id }`; + resultEvent = `${this.model.getModelName()}.value.result.${this.id}`; } else { - resultEvent = `${ this.parent.model.getModelName() }.${ this.relationship }.value.result.${ this.id }`; + resultEvent = `${this.parent.model.getModelName()}.${this.relationship}.value.result.${this.id}`; } this.socket.on(resultEvent, (res: any) => { if (res.error) { @@ -287,6 +302,9 @@ export class FireLoopRef { subject.next(res); } }); + if (event.match('dispose')) { + setTimeout(() => subject.next()); + } // This event listener will be wiped within socket.connections this.socket.sharedObservables.sharedOnDisconnect.subscribe(() => subject.complete()); return subject.asObservable().catch((error: any) => Observable.throw(error)); diff --git a/tests/ng2web/src/app/shared/sdk/services/core/real.time.ts b/tests/ng2web/src/app/shared/sdk/services/core/real.time.ts index fda2f795..ec3e1c74 100644 --- a/tests/ng2web/src/app/shared/sdk/services/core/real.time.ts +++ b/tests/ng2web/src/app/shared/sdk/services/core/real.time.ts @@ -1,7 +1,6 @@ import { Injectable, Inject } from '@angular/core'; import { IO } from './io.service'; import { LoopBackAuth } from './auth.service'; -import { LoopBackConfig } from '../../lb.config'; import { FireLoop } from '../../models/FireLoop'; import { SocketConnection } from '../../sockets/socket.connections'; import { SDKModels } from '../custom/SDKModels'; diff --git a/tests/ng2web/src/app/shared/sdk/services/custom/Account.ts b/tests/ng2web/src/app/shared/sdk/services/custom/Account.ts index fe942a8b..a742e922 100644 --- a/tests/ng2web/src/app/shared/sdk/services/custom/Account.ts +++ b/tests/ng2web/src/app/shared/sdk/services/custom/Account.ts @@ -1093,8 +1093,6 @@ export class AccountApi extends BaseLoopBackApi { } }; let _urlParams: any = {}; - if (typeof oldPassword !== 'undefined' && oldPassword !== null) _urlParams.oldPassword = oldPassword; - if (typeof newPassword !== 'undefined' && newPassword !== null) _urlParams.newPassword = newPassword; let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders); return result; } @@ -1123,7 +1121,6 @@ export class AccountApi extends BaseLoopBackApi { } }; let _urlParams: any = {}; - if (typeof newPassword !== 'undefined' && newPassword !== null) _urlParams.newPassword = newPassword; let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders); return result; } diff --git a/tests/ng2web/src/app/shared/sdk/services/custom/Storage.ts b/tests/ng2web/src/app/shared/sdk/services/custom/Storage.ts index d2155402..867735cd 100644 --- a/tests/ng2web/src/app/shared/sdk/services/custom/Storage.ts +++ b/tests/ng2web/src/app/shared/sdk/services/custom/Storage.ts @@ -262,8 +262,6 @@ export class StorageApi extends BaseLoopBackApi { let _routeParams: any = {}; let _postBody: any = {}; let _urlParams: any = {}; - if (typeof req !== 'undefined' && req !== null) _urlParams.req = req; - if (typeof res !== 'undefined' && res !== null) _urlParams.res = res; let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders); return result; } @@ -297,8 +295,6 @@ export class StorageApi extends BaseLoopBackApi { }; let _postBody: any = {}; let _urlParams: any = {}; - if (typeof req !== 'undefined' && req !== null) _urlParams.req = req; - if (typeof res !== 'undefined' && res !== null) _urlParams.res = res; let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders); return result; } diff --git a/tests/ng2web/src/app/shared/sdk/services/custom/User.ts b/tests/ng2web/src/app/shared/sdk/services/custom/User.ts index 583afe22..7f9668fa 100644 --- a/tests/ng2web/src/app/shared/sdk/services/custom/User.ts +++ b/tests/ng2web/src/app/shared/sdk/services/custom/User.ts @@ -486,8 +486,6 @@ export class UserApi extends BaseLoopBackApi { } }; let _urlParams: any = {}; - if (typeof oldPassword !== 'undefined' && oldPassword !== null) _urlParams.oldPassword = oldPassword; - if (typeof newPassword !== 'undefined' && newPassword !== null) _urlParams.newPassword = newPassword; let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders); return result; } @@ -516,7 +514,6 @@ export class UserApi extends BaseLoopBackApi { } }; let _urlParams: any = {}; - if (typeof newPassword !== 'undefined' && newPassword !== null) _urlParams.newPassword = newPassword; let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders); return result; } diff --git a/tests/ng2web/src/app/shared/sdk/sockets/socket.connections.ts b/tests/ng2web/src/app/shared/sdk/sockets/socket.connections.ts index 3ca1f106..1608b45d 100644 --- a/tests/ng2web/src/app/shared/sdk/sockets/socket.connections.ts +++ b/tests/ng2web/src/app/shared/sdk/sockets/socket.connections.ts @@ -162,6 +162,21 @@ export class SocketConnection { this.socket.off(event, handler); } } + /** + * @method removeAllListeners + * @param {string} event Event name + * @param {Function} handler Event listener handler + * @return {void} + * @description + * This method will wrap the original "on" method and run it within the Angular Zone + * Note: off is being used since the nativescript socket io client does not provide + * removeListener method, but only provides with off which is provided in any platform. + **/ + public removeAllListeners(event: string): void { + if (typeof this.socket.removeAllListeners === 'function') { + this.socket.removeAllListeners(event); + } + } /** * @method disconnect * @return {void}