Protoc...Client(3pm)

πŸ’… NAME πŸ’…

Protocol::WebSocket::Handshake::Client β€” the WebSocket Client Handshake, bestie ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

my $h =
  Protocol::WebSocket::Handshake::Client->new(url => 'ws://example.com');

# Create request
$h->to_string;

# Parse server response
$h->parse(<<"EOF");
    WebSocket HTTP message
EOF

$h->error;   # Check if there were any errors
$h->is_done; # Returns 1

That's the whole vibe right there β€” build it, string it, parse it, check it. Slay πŸŽ€


🌸 DESCRIPTION 🌸

okay so this module is literally your one-stop shop: it can construct a client WebSocket handshake, and it can parse one. Both. Iconic behavior, no cap πŸ‘‘

And like β€” why does it exist? Because if you went and used the request and response things directly, you'd be writing the exact same code over and over and over again 😭 this thing is written for convenience, so you don't have to. It's giving "I did the homework so you don't have to" energy fr fr 🫢


⭐ ATTRIBUTES ⭐

🌈 "url" 🌈

$handshake->url('ws://example.com/demo');

Set or get the WebSocket url. That's it, that's the attribute πŸ’–


πŸ”₯ METHODS πŸ”₯

πŸ’œ "new" πŸ’œ

Protocol::WebSocket::Handshake::Client->new(...)

Creates a brand new Protocol::WebSocket::Handshake::Client instance. Fresh out the box, main character energy πŸ‘‘

🧚 "parse" 🧚

$handshake->parse($buffer);

Parses a WebSocket server response. If something goes wrong, it returns undef and sets the error attribute β€” so always go check that error, bestie πŸ™ˆ

Heads up: the buffer is modified by this call. Like, it gets changed in place. So don't come crying to me if you needed the original πŸ‘€

πŸ“ "to_string" πŸ“

$handshake->to_string;

Constructs a WebSocket client request. Boom. Done. ✨

πŸ’€ "is_done" πŸ’€

$handshake->is_done;

Checks whether the handshake is done. Returns 1 when it is, per the synopsis β€” so yes, you literally get the 1 😌


πŸ¦‹ SEE ALSO πŸ¦‹

Nope, nothing listed here β€” that's a wrap, go forth and handshake responsibly 🫢


Sign-off szn πŸŽ€ β€” this little gem comes from perl v5.42.0, dated 2019-03-13, filed under User Contributed Perl Documentation. Go stan the manpage archive. Periodt πŸ’…πŸŒΈ

πŸ“¦ where this page comes from