Credo DRPC Module
DRPC module for Credo. Implements Aries RFC 0804.
Quick start
In order for this module to work, we have to inject it into the agent to access agent functionality. See the example for more information.
Example of usage
import { DrpcModule } from '@credo-ts/drpc'
const agent = new Agent({
config: {
},
dependencies: agentDependencies,
modules: {
drpc: new DrpcModule(),
},
})
await agent.initialize()
const responseListener = await senderAgent.modules.drpc.sendRequest(connectionId, {
jsonrpc: '2.0',
method: 'hello',
id: 1,
})
const { request, sendResponse } = await receiverAgent.modules.drpc.recvRequest()
const result =
request.method === 'hello'
? { jsonrpc: '2.0', result: 'Hello world!', id: request.id }
: { jsonrpc: '2.0', error: { code: DrpcErrorCode.METHOD_NOT_FOUND, message: 'Method not found' } }
await sendResponse(result)