.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Protocol::WebSocket::Frame 3pm" .TH Protocol::WebSocket::Frame 3pm "2019-03-09" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Protocol::WebSocket::Frame \- WebSocket Frame .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # Create frame \& my $frame = Protocol::WebSocket::Frame\->new(\*(Aq123\*(Aq); \& $frame\->to_bytes; \& \& # Parse frames \& my $frame = Protocol::WebSocket::Frame\->new; \& $frame\->append(...); \& $f\->next; # get next message \& $f\->next; # get another next message .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Construct or parse a WebSocket frame. .SH "RANDOM MASK GENERATION" .IX Header "RANDOM MASK GENERATION" By default built-in \f(CW\*(C`rand\*(C'\fR is used, this is not secure, so when Math::Random::Secure is installed it is used instead. .SH "METHODS" .IX Header "METHODS" .ie n .SS """new""" .el .SS "\f(CWnew\fP" .IX Subsection "new" .Vb 2 \& Protocol::WebSocket::Frame\->new(\*(Aqdata\*(Aq); # same as (buffer => \*(Aqdata\*(Aq) \& Protocol::WebSocket::Frame\->new(buffer => \*(Aqdata\*(Aq, type => \*(Aqclose\*(Aq); .Ve .PP Create a new Protocol::WebSocket::Frame instance. Automatically detect if the passed data is a Perl string (\s-1UTF\-8\s0 flag) or bytes. .PP When called with more than one arguments, it takes the following named arguments (all of them are optional). .ie n .IP """buffer"" => \s-1STR\s0 (default: """")" 4 .el .IP "\f(CWbuffer\fR => \s-1STR\s0 (default: \f(CW``''\fR)" 4 .IX Item "buffer => STR (default: """")" The payload of the frame. .ie n .IP """type"" => \s-1TYPE_STR\s0 (default: ""text"")" 4 .el .IP "\f(CWtype\fR => \s-1TYPE_STR\s0 (default: \f(CW``text''\fR)" 4 .IX Item "type => TYPE_STR (default: ""text"")" The type of the frame. Accepted values are: .Sp .Vb 6 \& continuation \& text \& binary \& ping \& pong \& close .Ve .ie n .IP """opcode"" => \s-1INT\s0 (default: 1)" 4 .el .IP "\f(CWopcode\fR => \s-1INT\s0 (default: 1)" 4 .IX Item "opcode => INT (default: 1)" The opcode of the frame. If \f(CW\*(C`type\*(C'\fR field is set to a valid string, this field is ignored. .ie n .IP """fin"" => \s-1BOOL\s0 (default: 1)" 4 .el .IP "\f(CWfin\fR => \s-1BOOL\s0 (default: 1)" 4 .IX Item "fin => BOOL (default: 1)" \&\*(L"fin\*(R" flag of the frame. \*(L"fin\*(R" flag must be 1 in the ending frame of fragments. .ie n .IP """masked"" => \s-1BOOL\s0 (default: 0)" 4 .el .IP "\f(CWmasked\fR => \s-1BOOL\s0 (default: 0)" 4 .IX Item "masked => BOOL (default: 0)" If set to true, the frame will be masked. .ie n .IP """version"" => \s-1VERSION_STR\s0 (default: \*(Aqdraft\-ietf\-hybi\-17\*(Aq)" 4 .el .IP "\f(CWversion\fR => \s-1VERSION_STR\s0 (default: \f(CW\*(Aqdraft\-ietf\-hybi\-17\*(Aq\fR)" 4 .IX Item "version => VERSION_STR (default: draft-ietf-hybi-17)" WebSocket protocol version string. See Protocol::WebSocket for valid version strings. .ie n .SS """is_continuation""" .el .SS "\f(CWis_continuation\fP" .IX Subsection "is_continuation" Check if frame is of continuation type. .ie n .SS """is_text""" .el .SS "\f(CWis_text\fP" .IX Subsection "is_text" Check if frame is of text type. .ie n .SS """is_binary""" .el .SS "\f(CWis_binary\fP" .IX Subsection "is_binary" Check if frame is of binary type. .ie n .SS """is_ping""" .el .SS "\f(CWis_ping\fP" .IX Subsection "is_ping" Check if frame is a ping request. .ie n .SS """is_pong""" .el .SS "\f(CWis_pong\fP" .IX Subsection "is_pong" Check if frame is a pong response. .ie n .SS """is_close""" .el .SS "\f(CWis_close\fP" .IX Subsection "is_close" Check if frame is of close type. .ie n .SS """opcode""" .el .SS "\f(CWopcode\fP" .IX Subsection "opcode" .Vb 2 \& $opcode = $frame\->opcode; \& $frame\->opcode(8); .Ve .PP Get/set opcode of the frame. .ie n .SS """masked""" .el .SS "\f(CWmasked\fP" .IX Subsection "masked" .Vb 2 \& $masked = $frame\->masked; \& $frame\->masked(1); .Ve .PP Get/set masking of the frame. .ie n .SS """append""" .el .SS "\f(CWappend\fP" .IX Subsection "append" .Vb 1 \& $frame\->append($chunk); .Ve .PP Append a frame chunk. .PP Beware that this method is \fBdestructive\fR. It makes \f(CW$chunk\fR empty unless \f(CW$chunk\fR is read-only. .ie n .SS """next""" .el .SS "\f(CWnext\fP" .IX Subsection "next" .Vb 1 \& $frame\->append(...); \& \& $frame\->next; # next message .Ve .PP Return the next message as a Perl string (\s-1UTF\-8\s0 decoded). .ie n .SS """next_bytes""" .el .SS "\f(CWnext_bytes\fP" .IX Subsection "next_bytes" Return the next message as is. .ie n .SS """to_bytes""" .el .SS "\f(CWto_bytes\fP" .IX Subsection "to_bytes" Construct a WebSocket message. .ie n .SS """max_payload_size""" .el .SS "\f(CWmax_payload_size\fP" .IX Subsection "max_payload_size" The maximum size of the payload. You may set this to \f(CW0\fR or \f(CW\*(C`undef\*(C'\fR to disable checking the payload size.