NAME
AnyEvent::WebSocket::Connection - WebSocket connection for AnyEvent
VERSION
version 0.08
SYNOPSIS
# send a message through the websocket...
$connection->send('a message');
# recieve message from the websocket...
$connection->on_each_message(sub {
my $message = shift;
...
});
# handle a closed connection...
$connection->on_finish(sub {
...
});
(See AnyEvent::WebSocket::Client on how to create a connection)
DESCRIPTION
This class represents a WebSocket connection with a remote server (or in the future perhaps a client).
If the connection object falls out of scope then the connection will be closed gracefully.
This class was created for a client to connect to a server via AnyEvent::WebSocket::Client, but it may be useful to reuse it for a server to interact with a client if a AnyEvent::WebSocket::Server
is ever created (after the handshake is complete, the client and server look pretty much the same).
METHODS
$connection->send($message)
Send a message to the other side.
$connection->on_each_message($cb)
Register a callback to be called on each subsequent message received. The message itself will be passed in as the only parameter to the callback.
$connection->on_next_message($cb)
Register a callback to be called the next message received. The message itself will be passed in as the only parameter to the callback.
$connection->on_finish($cb)
Register a callback to be called when the connection is closed.
SEE ALSO
AUTHOR
Graham Ollis <plicease@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.