How to use the jsonrpcserver.aio.methods.dispatch function in jsonrpcserver

To help you get started, we’ve selected a few jsonrpcserver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gdassori / spruned / spruned / application / jsonrpc_server.py View on Github external
async def _handle_request(self, request):
        result = {
            "id": request.get("id", 0),
            "result": None,
            "error": None
        }
        response = await methods.dispatch(request)
        result.update(response)
        if result['error'] and result['error']['code'] < -32:
            result['error']['code'] = -1
        return result, response.http_status
github icon-project / t-bears / tbears / server / jsonrpc_server.py View on Github external
async def dispatch(request):
        try:
            req = json.loads(request.body.decode())
            req["params"] = req.get("params", {})
        except JSONDecodeError:
            raise GenericJsonRpcServerError(
                code=-32700,
                message="Parse error",
                http_status=status.HTTP_BAD_REQUEST
            )
        else:
            res = await methods.dispatch(req)
            return sanic_response.json(res, status=res.http_status)
github trinity-project / trinity / gateway / discarded / jsonrpc.py View on Github external
async def handle(request):
        request = await request.text()
        # print(request)
        response = await methods.dispatch(request)
        if response.is_notification:
            return web.Response()
        else:
            return web.json_response(response, status=response.http_status)
github bcb / jsonrpcserver / examples / websockets_server.py View on Github external
async def main(websocket, path):
    request = await websocket.recv()
    response = await methods.dispatch(request)
    if not response.is_notification:
        await websocket.send(str(response))
github singnet / alpha-daemon / snetd_alpha / daemon.py View on Github external
async def handle(request):
        request = await request.text()
        response = await methods.dispatch(request)
        if response.is_notification:
            return web.Response()
        else:
            return web.json_response(response, status=response.http_status)
github trinity-project / trinity / gateway / network / jsonrpc.py View on Github external
async def handle(request):
        request = await request.text()
        response = await methods.dispatch(request)
        if response.is_notification:
            return web.Response()
        else:
            return web.json_response(response, status=response.http_status)