All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.bot.builder.core.AnonymousReceiveMiddleware Maven / Gradle / Ivy

package com.microsoft.bot.builder.core;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/// 
/// Helper class for defining middleware by using a delegate or anonymous method.
/// 
public class AnonymousReceiveMiddleware implements Middleware
{
    private MiddlewareCall _toCall;

    /// 
    /// Creates a middleware object that uses the provided method as its
    /// process request handler.
    /// 
    /// The method to use as the middleware's process
    /// request handler.
    public AnonymousReceiveMiddleware(MiddlewareCall anonymousMethod)
    {
        if (anonymousMethod == null)
            throw new NullPointerException("MiddlewareCall anonymousMethod");
        else
            _toCall = anonymousMethod;
    }

    /// 
    /// Uses the method provided in the  to
    /// process an incoming activity.
    /// 
    /// The context object for this turn.
    /// The delegate to call to continue the bot middleware pipeline.
    /// A task that represents the work queued to execute.
    public CompletableFuture OnTurn(TurnContext context, NextDelegate next) throws ExecutionException, InterruptedException {
        return _toCall.requestHandler(context, next);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy