AnyEvent-WebSocket-Client
view release on metacpan or search on metacpan
github_user = uperl
workflow = linux
workflow = windows
workflow = macos
workflow = msys2-mingw
[RemovePrereqs]
; comes with perl 5.8
remove = strict
remove = warnings
remove = utf8
remove = lib
remove = base
remove = Scalar::Util
remove = Carp
remove = Encode
remove = FindBin
remove = Exporter
; comes with mojo
remove = Mojo::Server::Daemon
t/anyevent_websocket_connection.t view on Meta::CPAN
use utf8;
use lib 't/lib';
use Test2::Plugin::EV;
use Test2::Plugin::AnyEvent::Timeout;
use Test2::V0 -no_srand => 1;
use Test2::Tools::WebSocket::Connection qw( create_connection_pair create_connection_and_handle );
use AnyEvent::WebSocket::Connection;
subtest 'send' => sub {
my($x,$y) = create_connection_pair;
t/anyevent_websocket_connection.t view on Meta::CPAN
);
};
{
my @test_data = (
{label => "single character", data => "a"},
{label => "5k bytes", data => "a" x 5000},
{label => "empty", data => ""},
{label => "0", data => 0},
{label => "utf8 charaters", data => 'ï¼µï¼´ï¼¦ï¼ ï¼·ï¼©ï¼¤ï¼¥ CHARACTERS'},
);
foreach my $case (@test_data)
{
subtest $case->{label} => sub {
is(
$round_trip->($case->{data}),
object {
call decoded_body => $case->{data};
},
t/mojo_echo.t view on Meta::CPAN
my $quit_cv = AnyEvent->condvar;
$connection->on(finish => sub {
$quit_cv->send("finished");
});
for my $testcase (
{label => "single character", data => "a"},
{label => "5k bytes", data => "a" x 5000},
{label => "empty", data => ""},
{label => "0", data => 0},
{label => "utf8 charaters", data => 'ï¼µï¼´ï¼¦ï¼ ï¼·ï¼©ï¼¤ï¼¥ CHARACTERS'},
{label => "quit", data => "quit"},
)
{
my $cv = AnyEvent->condvar;
$connection->on(next_message => sub {
my $message = pop->decoded_body;
$cv->send($message);
});
$connection->send($testcase->{data});
is $cv->recv, $testcase->{data}, "$testcase->{label}: echo succeeds";
t/mojo_receive.t view on Meta::CPAN
use utf8;
use lib 't/lib';
use Test2::Require::NotWindows;
use Test2::Require::Module 'EV';
use Test2::Require::Module 'Mojolicious' => '3.0';
use Test2::Require::Module 'Mojolicious::Lite';
use Test2::Plugin::AnyEvent::Timeout;
use Test2::V0 -no_srand => 1;
use Test2::Tools::WebSocket::Mojo qw( start_mojo );
use AnyEvent::WebSocket::Client;
use Mojolicious::Lite;
t/mojo_receive.t view on Meta::CPAN
use Encode qw(encode);
# NOTE: The mojo_* tests are to test interoperability with a really
# good implementation that is also written in Perl. Mojolicious
# tests should not be written for new features and to test bugs,
# unless they are also accompanied by a non-Mojolicious test as well!
my @test_cases = (
{ send => { binary => "hoge"}, recv_exp => ["hoge", "is_binary"] },
{ send => { text => "foobar"}, recv_exp => ["foobar", "is_text"] },
{ send => { binary => encode("utf8", "UTFã¼ï¼") }, recv_exp => [encode("utf8", "UTFã¼ï¼"), "is_binary"] },
{ send => { text => encode("utf8", "UTFã¼ï¼") }, recv_exp => [encode("utf8", "UTFã¼ï¼"), "is_text"] },
);
app->log->level('fatal');
websocket '/data' => sub {
my($self) = shift;
$self->on(message => sub {
my($self, $index) = @_;
$self->send($test_cases[$index]{send});
});
( run in 0.954 second using v1.01-cache-2.11-cpan-49f99fa48dc )