forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskillConversationIdFactory.js
31 lines (25 loc) · 982 Bytes
/
skillConversationIdFactory.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const { SkillConversationIdFactoryBase } = require('botbuilder');
/**
* A SkillConversationIdFactory that uses an in memory dictionary
*to store and retrieve ConversationReference instances.
*/
class SkillConversationIdFactory extends SkillConversationIdFactoryBase {
constructor() {
super();
this.refs = {};
}
async createSkillConversationId(conversationReference) {
const key = `${ conversationReference.channelId }:${ conversationReference.conversation.id }`;
this.refs[key] = conversationReference;
return key;
}
async getConversationReference(skillConversationId) {
return this.refs[skillConversationId];
}
async deleteConversationReference(skillConversationId) {
this.refs[skillConversationId] = undefined;
}
}
module.exports.SkillConversationIdFactory = SkillConversationIdFactory;