Class JsonRpcTransportWrapper

java.lang.Object
io.agentscope.core.a2a.server.transport.jsonrpc.JsonRpcTransportWrapper
All Implemented Interfaces:
TransportWrapper<String,Object>

public class JsonRpcTransportWrapper extends Object implements TransportWrapper<String,Object>
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 ServerCallContext from JSON-RPC method, headers and all metadata.
  • handle error and exception for JSON-RPC request handle.
  • Constructor Details

    • JsonRpcTransportWrapper

      public JsonRpcTransportWrapper(io.a2a.transport.jsonrpc.handler.JSONRPCHandler jsonrpcHandler)
  • Method Details

    • getTransportType

      public String getTransportType()
      Description copied from interface: TransportWrapper
      Get wrapper transport type name.
      Specified by:
      getTransportType in interface TransportWrapper<String,Object>
      Returns:
      name of transport type
    • 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.
      Specified by:
      handleRequest in interface TransportWrapper<String,Object>
      Parameters:
      body - JSON-RPC request body string
      headers - JSON-RPC request headers map
      metadata - Other JSON-RPC request metadata from request or developer.
      Returns:
      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.