in src/directLine.ts [992:1026]
private reconnectToConversation() {
return this.checkConnection(true)
.flatMap(_ =>
this.services.ajax({
method: "GET",
url: `${this.domain}/conversations/${this.conversationId}?watermark=${this.watermark}`,
timeout: this.timeout,
headers: {
"Accept": "application/json",
...this.commonHeaders()
}
})
.do(result => {
if (!this.secret)
this.token = result.response.token;
this.streamUrl = result.response.streamUrl;
})
.map(_ => null)
.retryWhen(error$ => error$
.mergeMap(error => {
if (error.status === 403) {
// token has expired. We can't recover from this here, but the embedding
// website might eventually call reconnect() with a new token and streamUrl.
this.expiredToken();
} else if (error.status === 404) {
return Observable.throw(errorConversationEnded, this.services.scheduler);
}
return Observable.of(error, this.services.scheduler);
})
.delay(this.timeout, this.services.scheduler)
.take(this.retries)
)
)
}