Skip to content

Commit

Permalink
Fix unacknowledged publishes being rejected in the OnPublish step
Browse files Browse the repository at this point in the history
Previously, the OnPublish promise was rejected because we don't have a publication ID to return.
Now, the API was changed to allow 'null' as value so we can resolve the promise with a 'null' value
to indicated that we don't have an acknowledge.
  • Loading branch information
martin31821 committed May 3, 2019
1 parent fd9e213 commit bab41c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/generic/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { WampMessage } from '../types/Protocol';
import { PendingMap } from '../util/map';

export class Publication implements IPublication {
private onPublished = new Deferred<WampID>();
private onPublished = new Deferred<WampID | null>();
private resolved = false;
constructor(private requestID: WampID, expectAck: boolean) {
if (!expectAck) {
this.onPublished.reject('acknowledge is not set, expecting no answer');
this.onPublished.resolve(null);
this.resolved = true;
}
}
Expand All @@ -32,7 +32,7 @@ export class Publication implements IPublication {
this.onPublished.resolve(publicationId);
}

public OnPublished(): Promise<WampID> {
public OnPublished(): Promise<WampID | null> {
return this.onPublished.promise;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export interface ISubscription {
}

export interface IPublication {
OnPublished(): Promise<WampID>;
OnPublished(): Promise<WampID | null>;
}

export interface IConnection {
Expand Down

0 comments on commit bab41c2

Please sign in to comment.