Skip to content

Commit

Permalink
Updates to LKG build
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevenic committed Jan 30, 2017
1 parent 4c7bc57 commit 21bf1b3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Node/core/lib/botbuilder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3014,6 +3014,13 @@ export class UniversalBot extends Library {
*/
isInConversation(address: IAddress, callback: (err: Error, lastAccess: Date) => void): void;

/**
* Loads a session object for an arbitrary address.
* @param address Address of the user/session to load. This should be saved during a previous conversation with the user.
* @param callback Function to invoke with the loaded session.
*/
loadSession(address: IAddress, callback: (err: Error, session: Session) => void): void;

/**
* Replaces the bots default route disambiguation logic with a custom implementation.
* @param handler Function that will be invoked with the candidate routes to dispatch an incoming message to.
Expand Down
42 changes: 40 additions & 2 deletions Node/core/lib/bots/UniversalBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,46 @@ var UniversalBot = (function (_super) {
UniversalBot.prototype.onDisambiguateRoute = function (handler) {
this._onDisambiguateRoute = handler;
};
UniversalBot.prototype.loadSession = function (address, done) {
var _this = this;
this.lookupUser(address, function (user) {
var msg = {
type: consts.messageType,
agent: consts.agent,
source: address.channelId,
sourceEvent: {},
address: utils.clone(address),
text: '',
user: user
};
_this.ensureConversation(msg.address, function (adr) {
msg.address = adr;
var conversationId = msg.address.conversation ? msg.address.conversation.id : null;
var storageCtx = {
userId: msg.user.id,
conversationId: conversationId,
address: msg.address,
persistUserData: _this.settings.persistUserData,
persistConversationData: _this.settings.persistConversationData
};
_this.createSession(storageCtx, msg, _this.settings.defaultDialogId || '/', _this.settings.defaultDialogArgs, done);
}, _this.errorLogger(done));
}, this.errorLogger(done));
};
UniversalBot.prototype.dispatch = function (storageCtx, message, dialogId, dialogArgs, done, newStack) {
var _this = this;
if (newStack === void 0) { newStack = false; }
this.createSession(storageCtx, message, dialogId, dialogArgs, function (err, session) {
if (!err) {
_this.emit('routing', session);
_this.routeMessage(session, done);
}
else {
done(err);
}
}, newStack);
};
UniversalBot.prototype.createSession = function (storageCtx, message, dialogId, dialogArgs, done, newStack) {
var _this = this;
if (newStack === void 0) { newStack = false; }
var loadedData;
Expand Down Expand Up @@ -280,8 +319,7 @@ var UniversalBot = (function (_super) {
delete session.privateConversationData[consts.Data.SessionState];
}
loadedData = data;
_this.emit('routing', session);
session.dispatch(sessionState, message, function () { return _this.routeMessage(session, done); });
session.dispatch(sessionState, message, function () { return done(null, session); });
}, done);
};
UniversalBot.prototype.routeMessage = function (session, done) {
Expand Down
2 changes: 1 addition & 1 deletion Node/core/lib/dialogs/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var ResumeReason;
var Dialog = (function (_super) {
__extends(Dialog, _super);
function Dialog() {
return _super !== null && _super.apply(this, arguments) || this;
return _super.apply(this, arguments) || this;
}
Dialog.prototype.begin = function (session, args) {
this.replyReceived(session);
Expand Down
2 changes: 1 addition & 1 deletion Node/core/lib/dialogs/Prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ exports.SimplePromptRecognizer = SimplePromptRecognizer;
var Prompts = (function (_super) {
__extends(Prompts, _super);
function Prompts() {
return _super !== null && _super.apply(this, arguments) || this;
return _super.apply(this, arguments) || this;
}
Prompts.prototype.begin = function (session, args) {
args = args || {};
Expand Down

0 comments on commit 21bf1b3

Please sign in to comment.