Skip to content

raymondsteers/protocol-websocket

 
 

Repository files navigation

MODIFICATION NOTES

Adding the ability to track overall incoming message sizes as the accumulate during frame fragmentation, then die if over a settable threshold. This works independant of number of frames and payload size. Please see Frame.pm

By trail and error it seems that Chrome will fragment at 128kb but safari does not. So if for example you set the max_mess_size to 256kb on the server but the max_recv_size to 128kb, you would be able to upload a 200kb file from Chrome but not from Safari.

NAME

Protocol::WebSocket - WebSocket protocol

SYNOPSIS

# Server side
my $hs = Protocol::WebSocket::Handshake::Server->new;

$hs->parse('some data from the client');

$hs->is_done; # tells us when handshake is done

my $frame = $hs->build_frame;

$frame->append('some data from the client');

while (defined(my $message = $frame->next)) {
    if ($frame->is_close) {

        # Send close frame back
        send(
            $hs->build_frame(
                type    => 'close',
                version => $version
            )->to_bytes
        );

        return;
    }

    # We got a message!
}

DESCRIPTION

Client/server WebSocket message and frame parser/constructor. This module does not provide a WebSocket server or client, but is made for using in http servers or clients to provide WebSocket support.

Protocol::WebSocket supports the following WebSocket protocol versions:

draft-ietf-hybi-17 (latest)
draft-ietf-hybi-10
draft-ietf-hybi-00 (with HAProxy support)
draft-hixie-75

By default the latest version is used. The WebSocket version is detected automatically on the server side. On the client side you have set a version attribute to an appropriate value.

Protocol::WebSocket itself does not contain any code and cannot be used directly. Instead the following modules should be used:

High-level modules

Server helper class.

Client helper class.

Low-level modules

Server handshake parser and constructor.

Client handshake parser and constructor.

WebSocket frame parser and constructor.

Low level WebSocket request parser and constructor.

Low level WebSocket response parser and constructor.

Low level WebSocket url parser and constructor.

EXAMPLES

For examples on how to use Protocol::WebSocket with various event loops see examples/ directory in the distribution.

CREDITS

In order of appearance:

Paul "LeoNerd" Evans

Jon Gentle

Lee Aylward

Chia-liang Kao

Atomer Ju

Chuck Bredestege

Matthew Lien (BlueT)

Joao Orui

Toshio Ito (debug-ito)

Neil Bowers

Michal Špaček

Graham Ollis

Anton Petrusevich

AUTHOR

Viacheslav Tykhanovskyi, [email protected].

COPYRIGHT

Copyright (C) 2010-2014, Viacheslav Tykhanovskyi.

This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10.

About

Protocol::WebSocket

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Perl 69.7%
  • Roff 30.3%