Skip to content

Commit

Permalink
fix(gbdialog): Trying to save context.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Rodriguez (pragmatismo.io) committed Dec 1, 2018
1 parent f0a0cd3 commit ce04290
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 172 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
/packages/default.gbui/node_modules
/tmp
/work
/packages/default.gbdialog/bot.js
/packages/default.gbdialog/bot.ts
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"botbuilder-choices": "^4.0.0-preview1.2",
"botbuilder-dialogs": "^4.1.5",
"botbuilder-prompts": "^4.0.0-preview1.2",
"botlib": "0.1.6",
"botlib": "^0.1.7",
"chai": "4.2.0",
"child_process": "^1.0.2",
"chokidar": "2.0.4",
Expand Down
20 changes: 11 additions & 9 deletions packages/core.gbapp/services/GBAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
'use strict';

import { TurnContext } from 'botbuilder';
import { WaterfallStepContext } from 'botbuilder-dialogs';
import { GBMinInstance } from 'botlib';
const WaitUntil = require('wait-until');

/**
* @fileoverview General Bots server core.
Expand All @@ -42,19 +44,21 @@ import { GBMinInstance } from 'botlib';
export class DialogClass {
public min: GBMinInstance;
public context: TurnContext;
public step: WaterfallStepContext;

constructor(min: GBMinInstance) {
this.min = min;
}

public hear(text: string) {
// TODO: await this.context.beginDialog('textPrompt', text);
}

public talk(text: string) {
this.context.sendActivity(text);
public async hear(cb) {
const id = Math.floor(Math.random() * 1000000000000);
this.min.cbMap[id] = cb;
await this.step.beginDialog('/feedback', { id: id });
}

public async talk(text: string) {
return await this.context.sendActivity(text);
}

/**
* Generic function to call any REST API.
Expand All @@ -67,7 +71,5 @@ export class DialogClass {
/**
* Generic function to call any REST API.
*/
public post(url: string, data) {

}
public post(url: string, data) {}
}
38 changes: 21 additions & 17 deletions packages/core.gbapp/services/GBCoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ export class GBCoreService implements IGBCoreService {
alter: alter,
force: force
});

} else {
const msg = `Database synchronization is disabled.`;
logger.info(msg);
Expand Down Expand Up @@ -239,9 +238,15 @@ export class GBCoreService implements IGBCoreService {
}

public async ensureProxy(port): Promise<string> {
const ngrok = require('ngrok');

return await ngrok.connect({ port: port });
try {
const ngrok = require('ngrok');
return await ngrok.connect({ port: port });
} catch (error) {
// There are false positive from ngrok regarding to no memory, but it's just
// lack of connection.
logger.verbose(error);
throw new Error('Error connecting to remote ngrok server, please check network connection.');
}
}

public async saveInstance(fullInstance: any) {
Expand Down Expand Up @@ -313,7 +318,6 @@ export class GBCoreService implements IGBCoreService {
}

public loadSysPackages(core: GBCoreService) {

// NOTE: if there is any code before this line a semicolon
// will be necessary before this line.
// Loads all system packages.
Expand Down Expand Up @@ -344,19 +348,19 @@ export class GBCoreService implements IGBCoreService {

public async createBootInstance(core: GBCoreService, azureDeployer: AzureDeployerService, proxyAddress: string) {
let instance: IGBInstance;
logger.info(`Deploying cognitive infrastructure (on the cloud / on premises)...`);
try {
instance = await azureDeployer.deployFarm(proxyAddress);
} catch (error) {
logger.warn(
`In case of error, please cleanup any infrastructure objects
logger.info(`Deploying cognitive infrastructure (on the cloud / on premises)...`);
try {
instance = await azureDeployer.deployFarm(proxyAddress);
} catch (error) {
logger.warn(
`In case of error, please cleanup any infrastructure objects
created during this procedure and .env before running again.`
);
throw error;
}
core.writeEnv(instance);
logger.info(`File .env written, starting General Bots...`);
GBConfigService.init();
);
throw error;
}
core.writeEnv(instance);
logger.info(`File .env written, starting General Bots...`);
GBConfigService.init();

return instance;
}
Expand Down

0 comments on commit ce04290

Please sign in to comment.