Skip to content

Commit

Permalink
Revert #171 and #172 (#240)
Browse files Browse the repository at this point in the history
* Reverting #171 and #172

* Add entry
  • Loading branch information
compulim committed Oct 25, 2019
1 parent 992fc6d commit 6ffe60a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Reverting PR [#171](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/171) and PR [#172](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/172), which caused infinite loop of reconnections, by [@compulim](https://github.com/compulim) in PR [#240](https://github.com/Microsoft/BotFramework-DirectLineJS/pull/240)

## [0.11.5] - 2019-09-30

### Breaking Changes
Expand Down
22 changes: 8 additions & 14 deletions src/directLine.ts
Expand Up @@ -410,8 +410,6 @@ export class DirectLine implements IBotConnection {

private tokenRefreshSubscription: Subscription;

private ending: boolean;

constructor(options: DirectLineOptions) {
this.secret = options.secret;
this.token = options.secret || options.token;
Expand Down Expand Up @@ -497,10 +495,7 @@ export class DirectLine implements IBotConnection {
.flatMap(connectionStatus => {
switch (connectionStatus) {
case ConnectionStatus.Ended:
if (this.ending)
return Observable.of(connectionStatus);
else
return Observable.throw(errorConversationEnded);
return Observable.throw(errorConversationEnded);

case ConnectionStatus.FailedToConnect:
return Observable.throw(errorFailedToConnect);
Expand Down Expand Up @@ -624,8 +619,13 @@ export class DirectLine implements IBotConnection {
end() {
if (this.tokenRefreshSubscription)
this.tokenRefreshSubscription.unsubscribe();
this.ending = true;
this.connectionStatus$.next(ConnectionStatus.Ended);
try {
this.connectionStatus$.next(ConnectionStatus.Ended);
} catch (e) {
if (e === errorConversationEnded)
return;
throw(e);
}
}

getSessionId(): Observable<string> {
Expand Down Expand Up @@ -863,12 +863,6 @@ export class DirectLine implements IBotConnection {

ws.onmessage = message => message.data && subscriber.next(JSON.parse(message.data));

ws.onerror = error => {
konsole.log("WebSocket error", error);
if (sub) sub.unsubscribe();
subscriber.error(error);
}

// This is the 'unsubscribe' method, which is called when this observable is disposed.
// When the WebSocket closes itself, we throw an error, and this function is eventually called.
// When the observable is closed first (e.g. when tearing down a WebChat instance) then
Expand Down

0 comments on commit 6ffe60a

Please sign in to comment.