/// <summary> /// Creates a new conversation on the specified channel. /// </summary> /// <param name="channelId">The ID of the channel.</param> /// <param name="callback">The bot logic to call when the conversation is created.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects /// or threads to receive notice of cancellation.</param> /// <returns>A task that represents the work queued to execute.</returns> /// <remarks>This resets the <see cref="ActiveQueue"/>, and does not maintain multiple converstion queues.</remarks> public Task CreateConversationAsync(string channelId, BotCallbackHandler callback, CancellationToken cancellationToken) { ActiveQueue.Clear(); var update = Activity.CreateConversationUpdateActivity(); update.Conversation = new ConversationAccount() { Id = Guid.NewGuid().ToString("n") }; var context = new TurnContext(this, (Activity)update); return(callback(context, cancellationToken)); }
/// <summary> /// NOTE: this resets the queue, it doesn't actually maintain multiple converstion queues /// </summary> /// <param name="channelId"></param> /// <param name="callback"></param> /// <returns></returns> //public override Task CreateConversation(string channelId, Func<ITurnContext, Task> callback) public Task CreateConversation(string channelId, Func <ITurnContext, Task> callback) { ActiveQueue.Clear(); var update = Activity.CreateConversationUpdateActivity(); update.Conversation = new ConversationAccount() { Id = Guid.NewGuid().ToString("n") }; var context = new TurnContext(this, (Activity)update); return(callback(context)); }
public override Task DeleteActivity(ITurnContext context, ConversationReference reference) { lock (_activeQueueLock) { var replies = ActiveQueue.ToList(); for (int i = 0; i < ActiveQueue.Count; i++) { if (replies[i].Id == reference.ActivityId) { replies.RemoveAt(i); ActiveQueue.Clear(); foreach (var item in replies) { ActiveQueue.Enqueue(item); } break; } } } return(Task.CompletedTask); }
public override Task <ResourceResponse> UpdateActivity(ITurnContext context, Activity activity) { lock (_activeQueueLock) { var replies = ActiveQueue.ToList(); for (int i = 0; i < ActiveQueue.Count; i++) { if (replies[i].Id == activity.Id) { replies[i] = activity; ActiveQueue.Clear(); foreach (var item in replies) { ActiveQueue.Enqueue(item); } return(Task.FromResult(new ResourceResponse(activity.Id))); } } } return(Task.FromResult(new ResourceResponse())); }