1Protocol::WebSocket(3pmU)ser Contributed Perl DocumentatiPornotocol::WebSocket(3pm)
2
3
4
6 Protocol::WebSocket - WebSocket protocol
7
9 # Server side
10 my $hs = Protocol::WebSocket::Handshake::Server->new;
11
12 $hs->parse('some data from the client');
13
14 $hs->is_done; # tells us when handshake is done
15
16 my $frame = $hs->build_frame;
17
18 $frame->append('some data from the client');
19
20 while (defined(my $message = $frame->next)) {
21 if ($frame->is_close) {
22
23 # Send close frame back
24 send(
25 $hs->build_frame(
26 type => 'close',
27 version => $version
28 )->to_bytes
29 );
30
31 return;
32 }
33
34 # We got a message!
35 }
36
38 Client/server WebSocket message and frame parser/constructor. This
39 module does not provide a WebSocket server or client, but is made for
40 using in http servers or clients to provide WebSocket support.
41
42 Protocol::WebSocket supports the following WebSocket protocol versions:
43
44 draft-ietf-hybi-17 (latest)
45 draft-ietf-hybi-10
46 draft-ietf-hybi-00 (with HAProxy support)
47 draft-hixie-75
48
49 By default the latest version is used. The WebSocket version is
50 detected automatically on the server side. On the client side you have
51 set a "version" attribute to an appropriate value.
52
53 Protocol::WebSocket itself does not contain any code and cannot be used
54 directly. Instead the following modules should be used:
55
56 High-level modules
57 Protocol::WebSocket::Server
58
59 Server helper class.
60
61 Protocol::WebSocket::Client
62
63 Client helper class.
64
65 Low-level modules
66 Protocol::WebSocket::Handshake::Server
67
68 Server handshake parser and constructor.
69
70 Protocol::WebSocket::Handshake::Client
71
72 Client handshake parser and constructor.
73
74 Protocol::WebSocket::Frame
75
76 WebSocket frame parser and constructor.
77
78 Protocol::WebSocket::Request
79
80 Low level WebSocket request parser and constructor.
81
82 Protocol::WebSocket::Response
83
84 Low level WebSocket response parser and constructor.
85
86 Protocol::WebSocket::URL
87
88 Low level WebSocket url parser and constructor.
89
91 For examples on how to use Protocol::WebSocket with various event loops
92 see "examples/" directory in the distribution.
93
95 In order of appearance:
96
97 Paul "LeoNerd" Evans
98
99 Jon Gentle
100
101 Lee Aylward
102
103 Chia-liang Kao
104
105 Atomer Ju
106
107 Chuck Bredestege
108
109 Matthew Lien (BlueT)
110
111 Joao Orui
112
113 Toshio Ito (debug-ito)
114
115 Neil Bowers
116
117 Michal XpaXek
118
119 Graham Ollis
120
121 Anton Petrusevich
122
123 Eric Wastl
124
126 Viacheslav Tykhanovskyi, "vti@cpan.org".
127
129 Copyright (C) 2010-2018, Viacheslav Tykhanovskyi.
130
131 This program is free software, you can redistribute it and/or modify it
132 under the same terms as Perl 5.10.
133
134
135
136perl v5.36.0 2022-07-22 Protocol::WebSocket(3pm)