in t/modules/proxy_websockets_ssl.t [32:81]
$client->connect("wss://$hostport/modules/lua/websockets.lua")->cb(sub {
our $connection = eval { shift->recv };
t_debug("wsoc connected");
if($@) {
# handle error...
warn $@;
$quit_program->send();
return;
}
# AnyEvent::WebSocket::Connection does not pass the PONG message down to the callback
# my $actualpingmsg = AnyEvent::WebSocket::Message->new(opcode => 0x09, body => "xxx");
# $connection->send($actualpingmsg);
foreach (@test_cases){
$connection->send($_);
}
$connection->on(finish => sub {
t_debug("finish");
$quit_program->send();
});
# recieve message from the websocket...
$connection->on(each_message => sub {
# $connection is the same connection object
# $message isa AnyEvent::WebSocket::Message
my($connection, $message) = @_;
$responses++;
t_debug("wsoc msg received: " . substr($message->body, 0, 5). " opcode " . $message->opcode);
if ("sendquit" eq $message->body) {
$connection->send('quit');
t_debug("closing");
$connection->close; # doesn't seem to close TCP.
$quit_program->send();
}
elsif ($message->body =~ /^ping(\d)/) {
my $offset = $1;
if ($message->body ne $test_cases[$offset]) {
t_debug("wrong data");
$surprised++;
}
}
else {
$surprised++;
}
});
});