Net-WebSocket-EV
view release on metacpan or search on metacpan
This callback is called when library receives complete message. Close messages aren't handled by this callback. When buffering is disabled $msg is always empty
Callback arguments: my ($rsv, $opcode, $msg, $status_code) = @_;
=item on_close
Called when connection is closed.
Callback arguments: my ($close_code) = @_;
=item genmask
Used only by Net::WebSocket::EV::Client. Must return $len bytes scalar to mask message. If not specified, then simple rand() mask generator is used.
Callback arguments: my ($len) = @_;
=item on_frame_recv_start
Called when frame header is received.
Callback arguments: my ($fin, $rsv,$opcode,$payload_length) = @_;
=item on_frame_recv_chunk
Called when next data portion is received.
Callback arguments: my ($data) = @_;
=item on_frame_recv_end
Called when message is received. No arguments
=back
=cut
=head2 queue_msg( message, opcode )
Queue message, opcode is optional default is 1 (text message)
=head2 queue_fragmented ( callback, opcode )
Queue fragmented message, opcode is optional, default is 2 (binary message)
Callback arguments: my ($len) = @_;
Callback must return array of two elements ( "scalar $len or less(can be 0) bytes length", status )
Status can be:
WS_FRAGMENTED_DATA - Data chunk, optional status value, you can just return one scalar with data. Wslay will constantly reinvoke callback when it returns WS_FRAGMENTED_DATA. It will let other events run, but you will get 100% cpu load if there is no ...
WS_FRAGMENTED_ERROR - Error. Don't call callback anymore
WS_FRAGMENTED_EOF - End of message.
=head2 wait(cb)
Callback called when send queue becomes empty. If callback isn't specified, then tryes to use Coro::rouse_cb & Coro::rouse_wait to block current coro.
=head2 queued_count()
Returns number of messages in send queue
=head2 start() and stop()
Start or stop all webosocket IO
=head2 start_read() and stop_write()
=head2 start_read() and stop_read()
=head2 shutdown_read() and shutdown_write()
Disable read or write. There is no way to enable it again, use start_* and stop_* instead
=head2 close( status_code, reason_data)
Queue close frame. Status and reason are optional.
Possible atack vector: client can hold connection after receiving close frame and make a lot of connections. So if you want to guaranteed close connection, then call $ws->close() and ->wait until close frame will be sent, then close socket by close($...
=cut
1;
( run in 0.778 second using v1.01-cache-2.11-cpan-e1769b4cff6 )