AnyEvent-WebSocket-Client

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    version when using this module. The older version of the API has since
    been deprecated and removed.

ATTRIBUTES

 timeout

    Timeout for the initial connection to the web server. The default is
    30.

 ssl_no_verify

    If set to true, then secure WebSockets (those that use SSL/TLS) will
    not be verified. The default is false.

 ssl_ca_file

    Provide your own CA certificates file instead of using the system
    default for SSL/TLS verification.

 protocol_version

lib/AnyEvent/WebSocket/Client.pm  view on Meta::CPAN

# ABSTRACT: WebSocket client for AnyEvent
our $VERSION = '0.55'; # VERSION


has timeout => (
  is      => 'ro',
  default => sub { 30 },
);


has ssl_no_verify => (
  is => 'ro',
);


has ssl_ca_file => (
  is => 'ro',
);


has protocol_version => (

lib/AnyEvent/WebSocket/Client.pm  view on Meta::CPAN

    my %subprotocol;
    if($self->subprotocol)
    {
      %subprotocol = map { $_ => 1 } @{ $self->subprotocol };
      $handshake->req->subprotocol(join(',', @{ $self->subprotocol }));
    }

    my $hdl = AnyEvent::Handle->new(
                                                      fh       => $fh,
      provided $uri->secure,                          tls      => 'connect',
      provided $uri->secure && !$self->ssl_no_verify, peername => $uri->host,
      provided $uri->secure && !$self->ssl_no_verify, tls_ctx  => {
                                                              verify => 1,
                                                              verify_peername => "https",
                                                        maybe ca_file => $self->ssl_ca_file,
                                                      },
                                                      on_error => sub {
                                                        my ($hdl, $fatal, $msg) = @_;
                                                        if($fatal)
                                                        { $done->croak("connect error: " . $msg) }
                                                        else
                                                        { warn $msg }
                                                      },
    );

lib/AnyEvent/WebSocket/Client.pm  view on Meta::CPAN

when using this module.  The older version of the API has since been
deprecated and removed.

=head1 ATTRIBUTES

=head2 timeout

Timeout for the initial connection to the web server.  The default
is 30.

=head2 ssl_no_verify

If set to true, then secure WebSockets (those that use SSL/TLS) will
not be verified.  The default is false.

=head2 ssl_ca_file

Provide your own CA certificates file instead of using the system default for
SSL/TLS verification.

=head2 protocol_version

t/anyevent_websocket_client__server_initial_data_shutdown.t  view on Meta::CPAN

      },
    );

    if($test_case->{tls})
    {
      $server_args{tls} = AnyEvent::TLS->new(cert => $test_case->{tls_cert});
    }

    my $url = start_server(%server_args);
    my $cv_finish = AnyEvent->condvar;
    my $conn = eval { AnyEvent::WebSocket::Client->new(ssl_no_verify => 1)->connect($url)->recv };
    if($@)
    {
      my $error = $@;
      die $error;
    }
    my @received_messages = ();
    $conn->on(each_message => sub {
      my ($conn, $message) = @_;
      push(@received_messages, $message->body);
    });

t/anyevent_websocket_client__ssl.t  view on Meta::CPAN

        $opt->{hdl}->push_write($opt->{frame}->new(type => 'close')->to_bytes);
        $opt->{hdl}->push_shutdown;
      }
    };
  },
);

$uri->path('/count/10');
note $uri;

my $connection = eval { AnyEvent::WebSocket::Client->new( ssl_no_verify => 1 )->connect($uri)->recv };

if(my $error = $@)
{
  die $error;
}

isa_ok $connection, 'AnyEvent::WebSocket::Connection';

my $done = AnyEvent->condvar;



( run in 0.484 second using v1.01-cache-2.11-cpan-5467b0d2c73 )