Skip to content

Commit

Permalink
fix: Fixed promise resolver creator
Browse files Browse the repository at this point in the history
  • Loading branch information
samwx committed Sep 26, 2019
1 parent 1c83f2d commit e051ff1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Lime/Protocol/Client/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ abstract class Channel implements MessageChannel, CommandChannel, NotificationCh
sessionId: string;
state: SessionState;
_commandResolves: {};
processCommandResolver: (command: Command) => any;

constructor(transport: Transport, autoReplyPings: boolean, autoNotifyReceipt: boolean) {
this.autoReplyPings = autoReplyPings;
Expand Down Expand Up @@ -68,7 +69,7 @@ abstract class Channel implements MessageChannel, CommandChannel, NotificationCh
if (responsePromise) {
delete this._commandResolves[command.id]

responsePromise.resolve(command);
this.processCommandResolver(command);
return;
}
}
Expand Down Expand Up @@ -107,7 +108,9 @@ abstract class Channel implements MessageChannel, CommandChannel, NotificationCh
abstract onMessage(message: Message): void;

processCommand(command: Command, timeout = this.commandTimeout): Promise<Command> {
const responsePromise = new Promise();
const responsePromise = new Promise(resolve => {
this.processCommandResolver = resolve;
});

this._commandResolves[command.id] = responsePromise;
const commandPromise = Promise.race([
Expand Down

0 comments on commit e051ff1

Please sign in to comment.