NAME
Net::WebSocket::Frame::close
SYNOPSIS
my $frm = Net::WebSocket::Frame::close->new(
#Optional, can be either empty (default) or four random bytes
mask => q<>,
code => 'SUCCESS', #See below
reason => 'yeah, baby', #See below
);
$frm->get_type(); #"close"
$frm->is_control_frame(); #1
my $mask = $frm->get_mask_bytes();
my ($code, $reason) = $frm->get_code_and_reason();
#If, for some reason, you need the raw payload:
my $payload = $frm->get_payload();
my $serialized = $frm->to_bytes();
Note that, as per RFC 6455, close messages can either have:
no code, and no reason
a code, and no reason
a code, and a reason that cannot exceed 123 bytes
The code (i.e., $code
) is subject to the limitations that RFC 6445 describes. You can also, in lieu of a numeric constant, use the following string constants that Microsoft defines:
SUCCESS (1000)
ENDPOINT_UNAVAILABLE (1001)
PROTOCOL_ERROR (1002)
INVALID_DATA_TYPE (1003)
INVALID_PAYLOAD (1007)
POLICY_VIOLATION (1008)
MESSAGE_TOO_BIG (1009)
UNSUPPORTED_EXTENSIONS (1010)
SERVER_ERROR (1011)