#json-rpc #websocket #server

bitconch-jsonrpc-ws-server

WebSockets server for JSON-RPC

1 unstable release

Uses old Rust 2015

0.1.0 Jun 1, 2019

#7 in #web-sockets

MIT license

31KB
851 lines

jsonrpc-ws-server

WebSockets server for JSON-RPC 2.0.

Documentation

Example

Cargo.toml

[dependencies]
jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc" }

main.rs

extern crate jsonrpc_ws_server;

use jsonrpc_ws_server::*;
use jsonrpc_ws_server::jsonrpc_core::*;

fn main() {
	let mut io = IoHandler::new();
	io.add_method("say_hello", |_params| {
		Ok(Value::String("hello".into()))
	});

	let server = ServerBuilder::new(io)
		.start(&"0.0.0.0:3030".parse().unwrap())
		.expect("Server must start with no issues");

	server.wait().unwrap()
}

lib.rs:

WebSockets server.

Dependencies

~16MB
~319K SLoC