W3WS.Rpc (w3ws v0.2.0)
W3WS RPC Server
This is useful for making arbitrary requests to the JSON-RPC server over a
websocket. This module ignores the id
field (if any) in given message as
it maintains it's own sequence.
Summary
Functions
Send a message to the RPC server and asynchronously receive the response as a message to the calling process.
Returns a specification to start this module under a supervisor.
Send a message to the RPC server.
Start an RPC server
Stop the RPC server
Types
rpc()
@type rpc() :: pid()
Functions
async_message(rpc, message)
@spec async_message(rpc(), map()) :: pos_integer()
Send a message to the RPC server and asynchronously receive the response as a message to the calling process.
Examples
receipt = Rpc.async_message(rpc, eth_block_number())
receive do
{:eth_response, ^receipt, response, _request} -> IO.inspect(response)
end
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
send_message(rpc, message)
Send a message to the RPC server.
This is a synchronous function which returns the response from the JSON-RPC server, but does not block the RPC process.
Examples
{:ok, result} = W3WS.Rpc.send_message(rpc, W3WS.Message.eth_block_number())
start_link(args)
Start an RPC server
Examples
{:ok, rpc} = W3WS.Rpc.start_link(uri: "ws://localhost:8545")
stop(rpc)
Stop the RPC server