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

NAME

Net::WAMP::RawSocket

SYNOPSIS

Client:

    my $rs = Net::WAMP::RawSocket::Client->new(

        #required
        io => IO::Framed::ReadWrite->new( $inet ),

        #optional
        max_pings           => 10,
        max_receive_length  => 2**23,    #default
    );

    #msgpack is also accepted
    $rs->send_handshake(
        serialization => 'json',    #default
    );

    $rs->verify_handshake();

    $rs->send_message('This is a message.);

    my $msg_txt = $rs->get_next_message();

Server:

    my $rs = Net::WAMP::RawSocket::Server->new(

        #required
        io => IO::Framed::ReadWrite->new( $inet ),

        #optional
        max_pings           => 10,
        max_receive_length  => 2**23,    #default
    );

    $rs->receive_and_answer_handshake();

    $rs->send_message('This is a message.);

    my $msg_txt = $rs->get_next_message();

DESCRIPTION

This module implements WAMP’s RawSocket protocol. It’s a simpler—and hopefully faster—protocol for speaking to a WAMP server when you have a raw TCP connection as opposed to a web browser.

Note that one of RawSocket’s limitations is a hard upper limit (16 MiB) on message size: if you want to send or receive single messages of over 16 MiB, you’ll need some other transport mechanism besides RawSocket.

GENERAL METHODS

CLASS->new( %OPTS )

Instantiates the relevant class. %OPTS are:

  • max_receive_length As per the protocol specification, this must be a power of 2 from 512 (2**9) to 16,777,216 (2**24), inclusive.

  • max_pings The number of pings to allow unanswered before we give up on the connection.

OBJ->send_message( MSG_STRING )

Sends a regular message.

OBJ->get_next_message()

Returns the next message string, or undef if no message is available. This will also (silently) consume any PONG messages that may arrive.

OBJ->check_heartbeat()

Run this when your read timeout expires to send a PING message.

OBJ->get_serialization()

json or msgpack.

OBJ->get_max_send_length()

The maximum bytes that the connection’s peer is willing to receive in a single RawSocket frame.