Protoc...Server(3pm)
πΈ NAME πΈ
okay so bestie, this is the manual page titled Protoc...Server(3pm) β yes, the title is literally truncated like that, no cap π β from User Contributed Perl Documentation. The actual module is Protocol::WebSocket::Handshake::Server, and its whole thing is WebSocket Server Handshake. Slay.
β¨ SYNOPSIS β¨
hereβs the vibe in code, fr fr:
my $h = Protocol::WebSocket::Handshake::Server->new;
# Parse client request
$h->parse(<<"EOF");
WebSocket HTTP message
EOF
$h->error; # Check if there were any errors
$h->is_done; # Returns 1
# Create response
$h->to_string;
π DESCRIPTION π
okay so you can construct or parse a server WebSocket handshake with this. Itβs written for convenience, since using request and response directly requires the same code again and again β and the way that gets old is honestly giving copy-paste nightmare π. This module ate that problem up. Periodt.
π METHODS π
main character methods incoming π
π¦ new π¦
Create a new Protocol::WebSocket::Handshake::Server instance. Thatβs it, thatβs the method, and itβs iconic.
π new_from_psgi π
Create a new Protocol::WebSocket::Handshake::Server instance from a PSGI environment. Hereβs the sample env and call, exactly:
my $env = {
HTTP_HOST => 'example.com',
HTTP_CONNECTION => 'Upgrade',
...
};
my $handshake = Protocol::WebSocket::Handshake::Server->new_from_psgi($env);
π
parse π
$handshake->parse($buffer);
$handshake->parse($handle);
Parse a WebSocket client request. On error it returns undef and sets the error attribute β so check that, bestie. Also heads up: when a buffer is passed in, it gets modified (unless itβs readonly). No cap, thatβs the deal.
π₯ build_frame π₯
$handshake->build_frame;
Builds a Protocol::WebSocket::Frame with an appropriate version. Obsessed with an appropriately versioned frame, honestly.
π to_string π
Construct a WebSocket server response. Thatβs the whole vibe.
π§ is_body π§
Check whether the handshake is in body state. Lowkey useful.
β is_done β
Check whether the handshake is done. When itβs done, you can move on with your main character energy.
and thatβs the page, bestie π«Άπ β itβs from perl v5.42.0, dated 2019-03-13, under the manual title Protoc...Server(3pm) (still truncated, still iconic π
). bye! β¨
π¦ 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