| 1 | package Net::WebSocket::X::ReceivedClose; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use parent qw( Net::WebSocket::X::Base ); | ||
| 7 | |||
| 8 | use Net::WebSocket::Constants (); | ||
| 9 | |||
| 10 | sub _new { | ||
| 11 | my ($class, $frame) = @_; | ||
| 12 | |||
| 13 | my $txt; | ||
| 14 | if ( my @code_reason = $frame->get_code_and_reason() ) { | ||
| 15 | my $status_name = Net::WebSocket::Constants::status_code_to_name($code_reason[0]); | ||
| 16 | if ($status_name) { | ||
| 17 | $code_reason[0] .= "/$status_name"; | ||
| 18 | } | ||
| 19 | |||
| 20 | pop @code_reason if !length $code_reason[1]; | ||
| 21 | |||
| 22 | $txt = "Received close frame: [@code_reason]"; | ||
| 23 | } | ||
| 24 | else { | ||
| 25 | $txt = "Received close frame (empty)"; | ||
| 26 | } | ||
| 27 | |||
| 28 | return $class->SUPER::_new( $txt, frame => $frame ); | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; |