Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allows RTMClient to transition from connecting to disconnecting #603

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/RTMClient.ts
Expand Up @@ -159,6 +159,7 @@ export class RTMClient extends EventEmitter {
this.teardownWebsocket();
})
.on('failure').transitionTo('disconnected')
.on('explicit disconnect').transitionTo('disconnecting')
.state('connected')
.onEnter(() => {
this.connected = true;
Expand Down Expand Up @@ -212,12 +213,10 @@ export class RTMClient extends EventEmitter {
})
.state('disconnecting')
.onEnter(() => {
// invariant: websocket exists and is open at the start of this state
// Most of the time, a websocket will exist. The only time it does not is when transitioning from connecting,
// before the rtm.start() has finished and the websocket hasn't been set up.
if (this.websocket !== undefined) {
this.websocket.close();
} else {
this.logger.error('Websocket not found when transitioning into disconnecting state. Please report to ' +
'@slack/client package maintainers.');
}
})
.on('websocket close').transitionTo('disconnected')
Expand Down