NAME
POE::Component::Client::MPD::Connection - module handling the tcp connection with mpd
VERSION
version 2.001
DESCRIPTION
This module will spawn a poe session responsible for low-level communication with mpd. It is written as a POE::Component::Client::TCP, which is taking care of everything needed.
Note that you're not supposed to use this class directly: it's one of the helper class for POE::Component::Client::MPD.
ATTRIBUTES
host
The hostname of the mpd server. Mandatory, no default.
port
The port of the mpd server. Mandatory, no default.
id
The POE session id of the peer to dialog with. Mandatory, no default.
max_retries
How much time to attempt reconnection before giving up. Defaults to 5.
retry_wait
How much time to wait (in seconds) before attempting socket reconnection. Defaults to 2.
METHODS
my $id = POE::Component::Client::MPD::Connection->spawn( \%params );
This method will create a POE::Component::Client::TCP session responsible for low-level communication with mpd.
It will return the poe id of the session newly created.
PUBLIC EVENTS ACCEPTED
disconnect( )
Request the pococm-connection to be shutdown. This does not shut down the MPD server. No argument.
send( $message )
Request pococm-conn to send the $message
over the wires. Note that this request is a POE::Component::Client::MPD::Message object properly filled up, and that the _commands()
attribute should not be newline terminated.
PUBLIC EVENTS FIRED
The following events are fired from the spawned session.
mpd_connected( $version )
Fired when the session is connected to a mpd server. This event isn't fired when the socket connection takes place, but when the session has checked that remote peer is a real mpd server. $version
is the advertised mpd server version.
mpd_connect_error_fatal( $errstr )
Fired when the session encounters a fatal error. This happens either when the session is connected to a server which happens to be something else than a mpd server, or if there was more than max_retries
(see spawn()
params) connection retries in a row. $errstr
will contain the problem encountered. No retries will be done.
mpd_connect_error_retriable( $errstr )
Fired when the session has troubles connecting to the server. $errstr
will point the faulty syscall that failed. Re-connection will be tried after $retry_wait
seconds (see spawn()
params).
mpd_data( $msg )
Fired when $msg
has been sent over the wires, and mpd server has answered with success. The actual output should be looked up in $msg-
_data>.
mpd_disconnected( )
Fired when the socket has been disconnected for whatever reason. Note that this event is not fired in the case of a programmed shutdown (see disconnect()
event above). A reconnection will be automatically re-tried after $retry_wait
(see spawn()
params).
mpd_error( $msg, $errstr )
Fired when $msg
has been sent over the wires, and mpd server has answered with the error message $errstr
.
AUTHOR
Jerome Quelin
COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.