Net::WebSocket::Handshake::Server
my $hsk = Net::WebSocket::Handshake::Server->new( #required, base 64 key => '..', #optional subprotocols => [ 'echo', 'haha' ], ); #Note the need to conclude the header text manually. #This is by design, so you can add additional headers. my $resp_hdr = $hsk->create_header_text() . "\x0d\x0a"; my $b64 = $hsk->get_accept();
This class implements WebSocket handshake logic for a server.
Because Net::WebSocket tries to be agnostic about how you parse your HTTP headers, this class doesn’t do a whole lot for you: it’ll give you the Sec-WebSocket-Accept header value given a base64 Sec-WebSocket-Key (i.e., from the client), and it’ll give you a “basic” response header text.
Sec-WebSocket-Accept
Sec-WebSocket-Key
NOTE: create_header_text() does NOT provide the extra trailing CRLF to conclude the HTTP headers. This allows you to add additional headers beyond what this class gives you.
create_header_text()
To install Net::WebSocket, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::WebSocket
CPAN shell
perl -MCPAN -e shell install Net::WebSocket
For more information on module installation, please visit the detailed CPAN module installation guide.