private startConversation()

in src/directLine.ts [626:664]


    private startConversation() {
        //if conversationid is set here, it means we need to call the reconnect api, else it is a new conversation
        const url = this.conversationId
            ? `${this.domain}/conversations/${this.conversationId}?watermark=${this.watermark}`
            : `${this.domain}/conversations`;
        const method = this.conversationId ? "GET" : "POST";
        const body = this.conversationId
            ? undefined
            : {
                user: {
                    id: this.userIdOnStartConversation
                },
                locale: this.localeOnStartConversation
              };
        return this.services.ajax({
            method,
            url,
            body,
            timeout: this.timeout,
            headers: {
                "Accept": "application/json",
                "Content-Type": "application/json",
                ...this.commonHeaders()
            }
        })
//      .do(ajaxResponse => konsole.log("conversation ajaxResponse", ajaxResponse.response))
        .map(ajaxResponse => ajaxResponse.response as Conversation)
        .retryWhen(error$ =>
            // for now we deem 4xx and 5xx errors as unrecoverable
            // for everything else (timeouts), retry for a while
            error$.mergeMap((error) => {
                return error.status >= 400 && error.status < 600
                ? Observable.throw(error, this.services.scheduler)
                : Observable.of(error, this.services.scheduler)
            })
            .delay(this.timeout, this.services.scheduler)
            .take(this.retries)
        )
    }