Skip to content

Event-driven JSON-RPC client with support for multiple transports

License

Notifications You must be signed in to change notification settings

witnet/async-jsonrpc-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-jsonrpc-client

Event-driven JSON-RPC client.

Introduction

This is a fork of the JSON-RPC client implementation from web3.

Supported transports:

  • HTTP
  • WebSockets
  • TCP

Usage

First, add the dependency in Cargo.toml. The required transports must be explicitely enabled as features:

async-jsonrpc-client = { version = "0.1.0", features = "ws" }

The available features are:

["http", "tcp", "ws", "tls"]

Where "tls" enables support for https and wss.

Example

A WebSockets client which sends a request and waits for the response:

use serde_json::json;
use async_jsonrpc_client::futures::Future;
use async_jsonrpc_client::transports::ws::WebSocket;
use async_jsonrpc_client::Transport;

fn main() {
    // Start server (starts tokio reactor in current thread)
    let (_handle, ws) = WebSocket::new("ws://127.0.0.1:3030").unwrap();

    // Send request
    let res = ws.execute("say_hello", json!({ "name": "Tomasz" }));

    // Wait for response
    let x = res.wait();

    println!("{:?}", x);
}

See also

About

Event-driven JSON-RPC client with support for multiple transports

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages