Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.subscribe((connectionStatus) => {
this.conectionStatus = connectionStatus;
switch (connectionStatus) {
case ConnectionStatus.Uninitialized:
// the status when the DirectLine object is first created/constructed
break;
case ConnectionStatus.Connecting:
// currently trying to connect to the conversation
if (program.verbose) {
console.log('Connecting to DirectLine...');
}
break;
case ConnectionStatus.Online:
// successfully connected to the converstaion. Connection is healthy so far as we know.
if (program.verbose) {
console.log('Connected to DirectLine.');
}
if (this.onReadyCb) {
this.onReadyCb();
}
break;
case ConnectionStatus.ExpiredToken:
// last operation errored out with an expired token. Your app should supply a new one.
console.log('DirectLine error: token expired.');
process.exit(1);
break;
case ConnectionStatus.FailedToConnect:
// the initial attempt to connect to the conversation failed. No recovery possible.
console.log('DirectLine error: failed to connect.');
}
if (this.onReadyCb) {
this.onReadyCb();
}
break;
case ConnectionStatus.ExpiredToken:
// last operation errored out with an expired token. Your app should supply a new one.
console.log('DirectLine error: token expired.');
process.exit(1);
break;
case ConnectionStatus.FailedToConnect:
// the initial attempt to connect to the conversation failed. No recovery possible.
console.log('DirectLine error: failed to connect.');
process.exit(1);
break;
case ConnectionStatus.Ended:
// the bot ended the conversation
break;
}
});
}
case ConnectionStatus.Connecting:
// currently trying to connect to the conversation
if (program.verbose) {
console.log('Connecting to DirectLine...');
}
break;
case ConnectionStatus.Online:
// successfully connected to the converstaion. Connection is healthy so far as we know.
if (program.verbose) {
console.log('Connected to DirectLine.');
}
if (this.onReadyCb) {
this.onReadyCb();
}
break;
case ConnectionStatus.ExpiredToken:
// last operation errored out with an expired token. Your app should supply a new one.
console.log('DirectLine error: token expired.');
process.exit(1);
break;
case ConnectionStatus.FailedToConnect:
// the initial attempt to connect to the conversation failed. No recovery possible.
console.log('DirectLine error: failed to connect.');
process.exit(1);
break;
case ConnectionStatus.Ended:
// the bot ended the conversation
break;
}
});
}
break;
case ConnectionStatus.Online:
// successfully connected to the converstaion. Connection is healthy so far as we know.
if (program.verbose) {
console.log('Connected to DirectLine.');
}
if (this.onReadyCb) {
this.onReadyCb();
}
break;
case ConnectionStatus.ExpiredToken:
// last operation errored out with an expired token. Your app should supply a new one.
console.log('DirectLine error: token expired.');
process.exit(1);
break;
case ConnectionStatus.FailedToConnect:
// the initial attempt to connect to the conversation failed. No recovery possible.
console.log('DirectLine error: failed to connect.');
process.exit(1);
break;
case ConnectionStatus.Ended:
// the bot ended the conversation
break;
}
});
}
.subscribe((connectionStatus) => {
this.conectionStatus = connectionStatus;
switch (connectionStatus) {
case ConnectionStatus.Uninitialized:
// the status when the DirectLine object is first created/constructed
break;
case ConnectionStatus.Connecting:
// currently trying to connect to the conversation
if (program.verbose) {
console.log('Connecting to DirectLine...');
}
break;
case ConnectionStatus.Online:
// successfully connected to the converstaion. Connection is healthy so far as we know.
if (program.verbose) {
console.log('Connected to DirectLine.');
}
if (this.onReadyCb) {
this.onReadyCb();
}
.subscribe((connectionStatus) => {
this.conectionStatus = connectionStatus;
switch (connectionStatus) {
case ConnectionStatus.Uninitialized:
// the status when the DirectLine object is first created/constructed
break;
case ConnectionStatus.Connecting:
// currently trying to connect to the conversation
if (program.verbose) {
console.log('Connecting to DirectLine...');
}
break;
case ConnectionStatus.Online:
// successfully connected to the converstaion. Connection is healthy so far as we know.
if (program.verbose) {
console.log('Connected to DirectLine.');
}
if (this.onReadyCb) {
this.onReadyCb();
}
break;
case ConnectionStatus.ExpiredToken:
// last operation errored out with an expired token. Your app should supply a new one.
componentDidMount() {
// Now that we're mounted, we know our dimensions. Put them in the store (this will force a re-render)
this.setSize();
const botConnection = this.props.directLine
? (this.botConnection = new DirectLine(this.props.directLine))
: this.props.botConnection
;
if (this.props.resize === 'window') {
window.addEventListener('resize', this.resizeListener);
}
this.store.dispatch({ type: 'Start_Connection', user: this.props.user, bot: this.props.bot, botConnection, selectedActivity: this.props.selectedActivity });
this.connectionStatusSubscription = botConnection.connectionStatus$.subscribe(connectionStatus => {
if (this.props.speechOptions && this.props.speechOptions.speechRecognizer) {
const refGrammarId = botConnection.referenceGrammarId;
if (refGrammarId) {
this.props.speechOptions.speechRecognizer.referenceGrammarId = refGrammarId;
}
}
componentDidMount() {
// Now that we're mounted, we know our dimensions. Put them in the store (this will force a re-render)
this.setSize();
const botConnection = this.props.directLine
? (this.botConnection = new DirectLine(this.props.directLine))
: this.props.botConnection
;
if (this.props.resize === 'window')
window.addEventListener('resize', this.resizeListener);
this.store.dispatch({ type: 'Start_Connection', user: this.props.user, bot: this.props.bot, botConnection, selectedActivity: this.props.selectedActivity });
this.connectionStatusSubscription = botConnection.connectionStatus$.subscribe(connectionStatus =>{
if(this.props.speechOptions && this.props.speechOptions.speechRecognizer){
let refGrammarId = botConnection.referenceGrammarId;
if(refGrammarId)
this.props.speechOptions.speechRecognizer.referenceGrammarId = refGrammarId;
}
this.store.dispatch({ type: 'Connection_Change', connectionStatus })
}
createConversation() {
console.log(this._token);
return new DirectLineWrapper(new DirectLine({
token: this._token,
webSocket: true
}));
}
getToken(directlineSecret) {
constructor(directLineSecret: string, domain?: string) {
super();
this.directLine = new DirectLine({ domain, secret: directLineSecret, webSocket: !domain });
this.subscribeToConnectionStatus();
}