Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'botframework-directlinejs' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
.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();
}