Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Added typing activity to activityhandler #837

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public CompletableFuture<Void> onTurn(TurnContext turnContext) {
case ActivityTypes.INSTALLATION_UPDATE:
return onInstallationUpdate(turnContext);

case ActivityTypes.TYPING:
return onTypingActivity(turnContext);

case ActivityTypes.INVOKE:
return onInvokeActivity(turnContext).thenCompose(invokeResponse -> {
// If OnInvokeActivityAsync has already sent an InvokeResponse, do not send
Expand Down Expand Up @@ -501,6 +504,17 @@ protected CompletableFuture<Void> onInstallationUpdate(TurnContext turnContext)
return CompletableFuture.completedFuture(null);
}

/**
* Override this in a derived class to provide logic specific to
* ActivityTypes.Typing activities.
*
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
protected CompletableFuture<Void> onTypingActivity(TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}

/**
* Invoked when an activity other than a message, conversation update, or event
* is received when the base behavior of {@link #onTurn(TurnContext)} is used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public void TestOnInstallationUpdate() {
Assert.assertEquals("onInstallationUpdate", bot.getRecord().get(0));
}

@Test
public void TestOnTypingActivity() {
Activity activity = new Activity(ActivityTypes.TYPING);
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);

TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();

Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onTypingActivity", bot.getRecord().get(0));
}

@Test
public void TestMemberAdded1() {
Activity activity = new Activity() {
Expand Down Expand Up @@ -449,6 +461,12 @@ protected CompletableFuture onInstallationUpdate(TurnContext turnContext) {
return super.onInstallationUpdate(turnContext);
}

@Override
protected CompletableFuture onTypingActivity(TurnContext turnContext) {
record.add("onTypingActivity");
return super.onTypingActivity(turnContext);
}

@Override
protected CompletableFuture onUnrecognizedActivityType(TurnContext turnContext) {
record.add("onUnrecognizedActivityType");
Expand Down