Skip to content

Commit

Permalink
Add parameter to specify clientMsgId generation in order to support c…
Browse files Browse the repository at this point in the history
…Tweb-12413 (#30)

* Add parameter to specify clientMsgId generation in order to support cTweb-12413

* Update version
  • Loading branch information
alexandr-bbm authored and dkaledin committed Mar 4, 2019
1 parent 186c833 commit 6719ffb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/connect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface IConnectionParams {
adapter: IConnectionAdapter;
instanceId: string;
payloadTypesNotAwaitingResponse?: number[];
generateClientMsgId?(): string;
}
export interface ISendCommand {
message: IMessage;
Expand All @@ -26,6 +27,7 @@ export declare class Connect {
private guaranteedCommandsToBeSent;
private pushEvents;
private payloadTypesNotAwaitingResponse;
private readonly generateClientMsgId;
constructor(params: IConnectionParams);
private subscribeToAdapter();
private onOpen();
Expand All @@ -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;
}
4 changes: 1 addition & 3 deletions lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -140,9 +141,6 @@ var Connect = (function () {
}
};
};
Connect.prototype.generateClientMsgId = function () {
return hat();
};
Connect.prototype.setPushEventHandler = function (callback) {
this.pushEvents.subscribe(callback);
};
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "connect-ts-api",
"version": "4.6.1",
"version": "4.6.2",
"main": "lib/connect.js",
"typings": "lib/connect",
"scripts": {
Expand Down Expand Up @@ -49,4 +49,4 @@
"tslint": "3.15.1",
"typescript": "2.3.0"
}
}
}
7 changes: 3 additions & 4 deletions src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface IConnectionParams {
adapter: IConnectionAdapter;
instanceId: string;
payloadTypesNotAwaitingResponse?: number[];
generateClientMsgId?(): string;
}

export interface ISendCommand {
Expand Down Expand Up @@ -39,11 +40,13 @@ export class Connect {
private guaranteedCommandsToBeSent: CacheCommand[] = [];
private pushEvents = new ReplaySubject<IMessage>(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();
}

Expand Down Expand Up @@ -178,10 +181,6 @@ export class Connect {
}
}

private generateClientMsgId(): string {
return hat();
}

public setPushEventHandler(callback: (data: IMessage) => void): void {
this.pushEvents.subscribe(callback);
}
Expand Down

0 comments on commit 6719ffb

Please sign in to comment.