BotFrameworkHttpClient 類別

public class BotFrameworkHttpClient
extends BotFrameworkClient

使用 BotFramework HTTP 通訊協定安全地將活動張貼到 Bot 的類別。 這個類別可用來使用 Bot Framework HTTP 通訊協定安全地將活動張貼至 Bot。 有 2 種使用模式:* 透過 PostActivity(fromBotId、toBotId、endpoint、serviceUrl、activity):* 透過 PostActivity(fromBotId、toBotId、endpoint、serviceUrl、activity)將活動張貼到自己 (外部服務 ->> Bot)完成,透過PostActivity(botId、端點、活動)完成的轉送活動,後者是由外部服務使用,例如需要使用 Bot 擁有認證將活動張貼至 Bot 的 Webjobs。

建構函式摘要

建構函式 Description
BotFrameworkHttpClient(CredentialProvider credentialProvider, ChannelProvider channelProvider)

初始化 BotFrameworkHttpClient 類別的新實例。

方法摘要

修飾詞與類型 方法與描述
java.util.concurrent.CompletableFuture<TypedInvokeResponse<T>> <T>postActivity(String fromBotId, String toBotId, URI toUrl, URI serviceUrl, String conversationId, Activity activity, Class<T> type)

將活動轉送至技能(Bot)。

java.util.concurrent.CompletableFuture<TypedInvokeResponse<T>> <T>postActivity(String botId, URI botEndpoint, Activity activity, Class<T> type)

使用 Bot 的認證將活動張貼至 Bot。

protected java.util.concurrent.CompletableFuture<AppCredentials> buildCredentials(String appId, String oAuthScope)

建置要用來取得此 getHttpClient() 之令牌的 AppCredentials 物件邏輯。

protected static java.util.Map<java.lang.String,AppCredentials> getAppCredentialMapCache()

取得應用程式快取認證以加速取得令牌(除非過期,否則不會要求令牌)。

protected ChannelProvider getChannelProvider()

取得這個配接器的通道提供者。

protected CredentialProvider getCredentialProvider()

取得這個配接器的認證提供者。

okhttp3.OkHttpClient getHttpClient()

取得這個配接器的 Http用戶端。

方法繼承來源 BotFrameworkClient

方法繼承來源 java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

建構函式詳細資料

BotFrameworkHttpClient

public BotFrameworkHttpClient(CredentialProvider credentialProvider, ChannelProvider channelProvider)

初始化 BotFrameworkHttpClient 類別的新實例。

參數:

credentialProvider - CredentialProvider 的實例。
channelProvider - ChannelProvider 的實例。

方法詳細資料

<T>postActivity

public CompletableFuture> postActivity(String fromBotId, String toBotId, URI toUrl, URI serviceUrl, String conversationId, Activity activity, Class type)

將活動轉送至技能(Bot)。 注意:將活動轉送至技能會排清 UserState 和 ConversationState 變更,讓技能具有精確的狀態。

覆寫:

BotFrameworkHttpClient.<T>postActivity(String fromBotId, String toBotId, URI toUrl, URI serviceUrl, String conversationId, Activity activity, Class<T> type)

參數:

fromBotId - 傳送活動的 Bot MicrosoftAppId。
toBotId - Bot 接收活動的 MicrosoftAppId。
toUrl - 接收活動的 Bot URL。
serviceUrl - 技能主機的回呼 URL。
conversationId - 用於與技能交談的交談 D。
activity - 要轉送的活動。
type

傳回:

具有選擇性 invokeResponse 的工作。

<T>postActivity

public CompletableFuture> postActivity(String botId, URI botEndpoint, Activity activity, Class type)

使用 Bot 的認證將活動張貼至 Bot。

參數:

botId - Bot 的 MicrosoftAppId。
botEndpoint - Bot 的 URL。
activity - 要張貼的活動。
type - 的類型。

傳回:

InvokeResponse。

buildCredentials

protected CompletableFuture buildCredentials(String appId, String oAuthScope)

建置 AppCredentials 對象的邏輯,用來取得此 getHttpClient() 的令牌。

參數:

appId - 應用程式識別碼。
oAuthScope - 選擇性的 OAuth 範圍。

傳回:

要用來取得令牌的應用程式認證。

getAppCredentialMapCache

protected static Map getAppCredentialMapCache()

取得快取 appCredentials 以加速取得令牌(除非過期,否則不會要求令牌)。 AppCredentials 是使用 appId + scope 快取的(只有當應用程式認證用來呼叫技能時,才會使用這個最後一個參數)。

傳回:

AppCredentialMapCache 值做為靜態 ConcurrentDictionary<String、AppCredentials>。

getChannelProvider

protected ChannelProvider getChannelProvider()

取得這個配接器的通道提供者。

傳回:

ChannelProvider 值做為 getChannelProvider()。

getCredentialProvider

protected CredentialProvider getCredentialProvider()

取得這個配接器的認證提供者。

傳回:

CredentialProvider 值做為 getCredentialProvider()。

getHttpClient

public OkHttpClient getHttpClient()

取得這個配接器的 HttpClient。

傳回:

OkHTTPClient 值做為 getHttpClient()。

適用於