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
- opensuse-leap 16.0: perl-Protocol-WebSocket 0.26-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms