The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Async::Blockchain::Client::Websocket - Async websocket Client.

SYNOPSIS

    my $loop = IO::Async::Loop->new();

    $loop->add(my $ws_source = Ryu::Async->new());

    $loop->add(
        my $client = Net::Async::Blockchain::Client::Websocket->new(
            endpoint => "ws://127.0.0.1:8546",
        )
    );

    $client->eth_subscribe('newHeads')->each(sub {print shift->{hash}})->get;

DESCRIPTION

Auto load the commands as the method parameters for the websocket calls returning them asynchronously.

source

Create an Ryu::Source instance, if it is already defined just return the object

Ryu::Source

endpoint

Websocket endpoint

URL containing the port if needed

latest_subscription

Latest subscription sent from this module

websocket_client

Create an Net::Async::WebSocket::Client instance, if it is already defined just return the object

Net::Async::WebSocket::Client

configure

Any additional configuration that is not described on IO::Async::Notifier must be included and removed here.

  • endpoint

_request

Prepare the data to be sent to the websocket and call the request

  • method

  • @_ - any parameter required by the RPC call

Ryu::Source

shutdown

run the configured shutdown action if any

  • error error message

eth_subscribe

Subscribe to an event

  • method

  • @_ - any parameter required by the RPC call

INHERITED METHODS

IO::Async::Notifier

add_child, adopt_future, adopted_futures, can_event, children, configure_unknown, debug_printf, get_loop, invoke_error, invoke_event, loop, make_event_cb, maybe_invoke_event, maybe_make_event_cb, new, notifier_name, parent, remove_child, remove_from_parent