Protocol::WebSocket::Client(3pm)

Protocol::WebSocket::Client3pm

Websocket client

Usage

    my $sock = ...get non-blocking socket...;
    my $client = Protocol::WebSocket->new(url => 'ws://localhost:3000');
    $client->on(
        write => sub {
            my $client = shift;
            my ($buf) = @_;
            syswrite $sock, $buf;
        }
    );
    $client->on(
        read => sub {
            my $client = shift;
            my ($buf) = @_;
            ...do smth with read data...
        }
    );
    # Sends a correct handshake header
    $client->connect;
    # Register on connect handler
    $client->on(
        connect => sub {
            $client->write('hi there');
        }
    );
    # Parses incoming data and on every frame calls on_read
    $client->read(...data from socket...);
    # Sends correct close header
    $client->disconnect;

Overview

Protocol::WebSocket::Client is a convenient class for writing a WebSocket client.

Releases

3 releases since Debian 11 (Bullseye); the text changed 1 time.

  1. 11
  2. 12–13

From libprotocol-websocket-perl 0.26-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.