Skip to content

Commit

Permalink
Ensure we continue processin commands when reconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Mar 21, 2018
1 parent 8826d80 commit ef49248
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/adapter/0_6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Adapter {
this.commands = [];
this.listener = null;
this.subscribe();
this.tick();
}

subscribe() {
Expand All @@ -22,6 +23,12 @@ class Adapter {
}, err => this.client.protocolError(err));
};
this.client.transport.on('message', onMessage);
this.client.transport.on('status', ({ online }) => {
if (!online) {
return;
}
this.tick();
});
}

send(protocol, command, payload) {
Expand Down
2 changes: 0 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ class FbpClient extends EventEmitter {

prepareAdapter(version) {
if (this.adapter) {
this.adapter.tick();
return;
}
// TODO: Semver comparison?
const versionNumber = Number.parseFloat(version);
if (versionNumber <= 0.6) {
this.adapter = adapter06(this);
this.adapter.tick();
return;
}
throw new Error(`Unsupported FBP protocol version ${version}`);
Expand Down

0 comments on commit ef49248

Please sign in to comment.