Protoc...bSocket(3pm)

πŸ’– NAME πŸ’–

okay so this is the Protocol::WebSocket(3pm) page from the User Contributed Perl Documentation, and the module itself is literally called Protocol::WebSocket β€” the WebSocket protocol πŸ’…βœ¨

πŸ¦‹ SYNOPSIS πŸ¦‹

# Server side
my $hs = Protocol::WebSocket::Handshake::Server->new;

$hs->parse('some data from the client');

$hs->is_done; # tells us when handshake is done

my $frame = $hs->build_frame;

$frame->append('some data from the client');

while (defined(my $message = $frame->next)) {
    if ($frame->is_close) {

        # Send close frame back
        send(
            $hs->build_frame(
                type    => 'close',
                version => $version
            )->to_bytes
        );

        return;
    }

    # We got a message!
}

🌸 DESCRIPTION 🌸

bestie, Protocol::WebSocket is a client/server WebSocket message and frame parser/constructor. It does not hand you a full WebSocket server or client β€” it's made for using in http servers or clients so they can provide WebSocket support 🫢

It supports these WebSocket protocol versions, no cap:

  • draft-ietf-hybi-17 (latest)
  • draft-ietf-hybi-10
  • draft-ietf-hybi-00 (with HAProxy support)
  • draft-hixie-75

By default, the latest version is used β€” periodt. On the server side, the WebSocket version gets detected automatically ✨ On the client side, you set a version attribute to an appropriate value.

real talk: Protocol::WebSocket itself does not contain any code and cannot be used directly 😭 Instead, you gotta use the modules below.

🌈 High-level modules 🌈

  • Protocol::WebSocket::Server β€” server helper class, your server-side bestie 🫢
  • Protocol::WebSocket::Client β€” client helper class, the client-side icon πŸ’…

🧚 Low-level modules 🧚

  • Protocol::WebSocket::Handshake::Server β€” server handshake parser and constructor.
  • Protocol::WebSocket::Handshake::Client β€” client handshake parser and constructor.
  • Protocol::WebSocket::Frame β€” WebSocket frame parser and constructor.
  • Protocol::WebSocket::Request β€” low level WebSocket request parser and constructor.
  • Protocol::WebSocket::Response β€” low level WebSocket response parser and constructor.
  • Protocol::WebSocket::URL β€” low level WebSocket url parser and constructor.

⭐ EXAMPLES ⭐

For examples on how to use Protocol::WebSocket with various event loops, see the examples/ directory in the distribution πŸ‘€βœ¨

πŸŽ€ CREDITS πŸŽ€

In order of appearance:

  • Paul "LeoNerd" Evans
  • Jon Gentle
  • Lee Aylward
  • Chia-liang Kao
  • Atomer Ju
  • Chuck Bredestege
  • Matthew Lien (BlueT)
  • Joao Orui
  • Toshio Ito (debug-ito)
  • Neil Bowers
  • Michal Ε paček
  • Graham Ollis
  • Anton Petrusevich
  • Eric Wastl

πŸ‘‘ AUTHOR πŸ‘‘

Viacheslav Tykhanovskyi, "vti@cpan.org" πŸ’Œ

Copyright (C) 2010-2018, Viacheslav Tykhanovskyi.

This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10 ✨


mwah πŸ’‹ β€” this whole vibe is Protoc...bSocket(3pm) from perl v5.42.0, dated 2019-03-13. bye bestie, go build something iconic πŸŽ€πŸ’–

πŸ“¦ where this page comes from