diff --git a/lib/connect.d.ts b/lib/connect.d.ts index 2cced96..f269aaa 100644 --- a/lib/connect.d.ts +++ b/lib/connect.d.ts @@ -7,6 +7,7 @@ export interface IConnectionParams { adapter: IConnectionAdapter; instanceId: string; payloadTypesNotAwaitingResponse?: number[]; + generateClientMsgId?(): string; } export interface ISendCommand { message: IMessage; @@ -26,6 +27,7 @@ export declare class Connect { private guaranteedCommandsToBeSent; private pushEvents; private payloadTypesNotAwaitingResponse; + private readonly generateClientMsgId; constructor(params: IConnectionParams); private subscribeToAdapter(); private onOpen(); @@ -39,6 +41,5 @@ export declare class Connect { sendCommand(command: ISendCommand): ISubscribableCommand; private getSubscribableForList(cachedCommand, listUsed); private getEmptySubscribable(); - private generateClientMsgId(); setPushEventHandler(callback: (data: IMessage) => void): void; } diff --git a/lib/connect.js b/lib/connect.js index 1d11b81..33fd927 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -12,6 +12,7 @@ var Connect = (function () { this.instanceId = params.instanceId || 'connect'; this.adapter = params.adapter; this.payloadTypesNotAwaitingResponse = params.payloadTypesNotAwaitingResponse || []; + this.generateClientMsgId = params.generateClientMsgId || hat; this.subscribeToAdapter(); } Connect.prototype.subscribeToAdapter = function () { @@ -140,9 +141,6 @@ var Connect = (function () { } }; }; - Connect.prototype.generateClientMsgId = function () { - return hat(); - }; Connect.prototype.setPushEventHandler = function (callback) { this.pushEvents.subscribe(callback); }; diff --git a/package-lock.json b/package-lock.json index 25eac65..a94eaa3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "connect-ts-api", - "version": "4.5.1", + "version": "4.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e1ea09e..41f950b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "connect-ts-api", - "version": "4.6.1", + "version": "4.6.2", "main": "lib/connect.js", "typings": "lib/connect", "scripts": { @@ -49,4 +49,4 @@ "tslint": "3.15.1", "typescript": "2.3.0" } -} \ No newline at end of file +} diff --git a/src/connect.ts b/src/connect.ts index 73e11ba..b79588b 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -11,6 +11,7 @@ export interface IConnectionParams { adapter: IConnectionAdapter; instanceId: string; payloadTypesNotAwaitingResponse?: number[]; + generateClientMsgId?(): string; } export interface ISendCommand { @@ -39,11 +40,13 @@ export class Connect { private guaranteedCommandsToBeSent: CacheCommand[] = []; private pushEvents = new ReplaySubject(1); private payloadTypesNotAwaitingResponse: number[]; + private readonly generateClientMsgId: () => string; constructor(params: IConnectionParams) { this.instanceId = params.instanceId || 'connect'; this.adapter = params.adapter; this.payloadTypesNotAwaitingResponse = params.payloadTypesNotAwaitingResponse || []; + this.generateClientMsgId = params.generateClientMsgId || hat; this.subscribeToAdapter(); } @@ -178,10 +181,6 @@ export class Connect { } } - private generateClientMsgId(): string { - return hat(); - } - public setPushEventHandler(callback: (data: IMessage) => void): void { this.pushEvents.subscribe(callback); }