Skip to content

Commit

Permalink
Consider connection established on first packet.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptx2 committed Feb 1, 2021
1 parent a959906 commit 32420d1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bikes/peloton.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export class PelotonBikeClient extends EventEmitter {
await open();
this._port.on('close', this.onSerialClose);
this._parser = this._port.pipe(new Delimiter({ delimiter: PACKET_DELIMITER }));
const connected = once(this._parser, 'data');
this._parser.on('data', this.onSerialMessage);
// consider the connection established when the first packet arrives
await connected;

this.state = 'connected';
}
Expand Down

0 comments on commit 32420d1

Please sign in to comment.