Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _login() {
this.setState({
isBotInitializing :true,
showPanel: true,
});
// Get the conversation id if there is one. Otherwise, a new one will be created
const conversationId = this._storage.local.get(this.CONVERSATION_ID_KEY);
// Initialize the bot connection direct line
this._botConnection = new DirectLine({
secret: this._directLineSecret,
webSocket: false, // Needed to be able to retrieve history
conversationId: conversationId ? conversationId : null,
});
this._botConnection.connectionStatus$
.subscribe((connectionStatus) => {
switch (connectionStatus) {
// Successfully connected to the converstaion.
case ConnectionStatus.Online :
if (!conversationId) {
// Store the current conversation id in the browser session storage
// with 15 minutes expiration
this._storage.local.put(
this.CONVERSATION_ID_KEY, this._botConnection["conversationId"],
Util.dateAdd(new Date(), "minute", 15)
}
let botChanged = false;
if (this.botId !== settings.serverSettings.activeBot) {
this.botId = settings.serverSettings.activeBot || '';
botChanged = true;
}
if (conversationChanged || userChanged || botChanged) {
if (this.directline) {
this.directline.end();
this.directline = undefined;
// log.debug(`ended conversation`);
}
if (this.conversationId.length && this.userId.length && this.botId.length) {
this.directline = new BotChat.DirectLine({
secret: settings.conversation.conversationId,
token: settings.conversation.conversationId,
domain: `${Emulator.serviceUrl}/v3/directline`,
webSocket: false
});
// log.debug(`started new conversation`);
}
this.reuseKey++;
this.forceUpdate();
}
} catch(e) {
//log.error(e.message);
}
this.setState({
showUpdateDialog: settings.update.showing,
updateVersion: settings.update.version