AS AgentScopeAPI 手册 / API Reference

JsonRpcTransportWrapper

public class JsonRpcTransportWrapper implements TransportWrapper<String, Object>
源码Source io/agentscope/core/a2a/server/transport/jsonrpc/JsonRpcTransportWrapper.java:77–253

包装器用于 JSON-RPC 传输层请求。位于 io.agentscope.core.a2a.server.transport.jsonrpc 包,实现 TransportWrapper<String, Object>。核心成员包括 getTransportType、handleRequest、JsonRpcTransportWrapper。

The Wrapper for JSON-RPC transport request.

wrapper all JSON-RPC request pre-handle logic, developer should get string body and some headers and metadata from request.

The pre-handle logic with:

  • deserialize request body to JSON-RPC request.

  • judge whether the request is streaming request.

  • build io.a2a.server.ServerCallContext from JSON-RPC method, headers and all metadata.

  • handle error and exception for JSON-RPC request handle.

构造器摘要Constructor Summary

构造器Constructor说明Description
public JsonRpcTransportWrapper(JSONRPCHandler jsonrpcHandler)
初始化 `JsonRpcTransportWrapper` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String getTransportType()
获取传输层类型。
Returns the transport type.
public Object handleRequest(String body, Map<String, String> headers, Map<String, Object> metadata)
处理请求。
Do handle for JSON-RPC Request, including streaming and non-streaming request.

构造器详情Constructor Detail

JsonRpcTransportWrapper

public JsonRpcTransportWrapper(JSONRPCHandler jsonrpcHandler)

初始化 JsonRpcTransportWrapper 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
jsonrpcHandlerJSONRPCHandlerjsonrpc 处理器(类型 `JSONRPCHandler`)。The jsonrpc handler.
源码Source io/agentscope/core/a2a/server/transport/jsonrpc/JsonRpcTransportWrapper.java:93–95

方法详情Method Detail

getTransportType

public String getTransportType()

获取传输层类型。

Returns the transport type.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/a2a/server/transport/jsonrpc/JsonRpcTransportWrapper.java:97–100

handleRequest

public Object handleRequest(String body, Map<String, String> headers, Map<String, Object> metadata)

处理请求。

Do handle for JSON-RPC Request, including streaming and non-streaming request.

参数Parameters
名称Name类型Type说明Description
bodyString正文(类型 `String`)。JSON-RPC request body string
headersMap<String, String>请求头(类型 `Map`)。JSON-RPC request headers map
metadataMap<String, Object>元数据(类型 `Map`)。Other JSON-RPC request metadata from request or developer.
返回Returns Object
返回对象。Two type according to the request whether streaming request: If streaming request, return `Flux` with `JSONRPCResponse`, otherwise only single `JSONRPCResponse`. When handle with error or exceptions, will return `JSONRPCErrorResponse`.
源码Source io/agentscope/core/a2a/server/transport/jsonrpc/JsonRpcTransportWrapper.java:112–135
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.