registerRpcMethod method
- String method,
- RpcRequestHandler handler
Register a handler for incoming RPC requests. @param method, the method name to listen for. When a request with this method name is received, the handler will be called. The handler should return a string payload to send back to the caller. If the handler returns null, an error will be sent back to the caller.
Implementation
void registerRpcMethod(String method, RpcRequestHandler handler) {
if (rpcHandlers.containsKey(method)) {
throw Exception('Method $method already registered');
}
rpcHandlers[method] = handler;
}