Protocol::WebSocket3pm
Websocket protocol
Usage
# Server sidemy $hs = Protocol::WebSocket::Handshake::Server->new;$hs->parse('some data from the client');$hs->is_done; # tells us when handshake is donemy $frame = $hs->build_frame;$frame->append('some data from the client');while (defined(my $message = $frame->next)) {if ($frame->is_close) {# Send close frame backsend($hs->build_frame(type => 'close',version => $version)->to_bytes);return;}# We got a message!}
Overview
Client/server WebSocket message and frame parser/constructor. This module does not provide a WebSocket server or client, but is made for using in http servers or clients to provide WebSocket support.
Protocol::WebSocket supports the following WebSocket protocol versions:
draft-ietf-hybi-17 (latest)draft-ietf-hybi-10draft-ietf-hybi-00 (with HAProxy support)draft-hixie-75
By default the latest version is used. The WebSocket version is detected automatically on the server side. On the client side you have set a "version" attribute to an appropriate value.
Protocol::WebSocket itself does not contain any code and cannot be used directly. Instead the following modules should be used:
High-level modules
Protocol::WebSocket::Server
Server helper class.
Protocol::WebSocket::Client
Client helper class.
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 "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 XpaXek
Graham Ollis
Anton Petrusevich
Eric Wastl
Releases
3 releases since Debian 11 (Bullseye); the text changed 1 time.