POE::Component::Client::MPD::Connection.3pm

Langue: en

Autres versions - même langue

Version: 2009-11-08 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

POE::Component::Client::MPD::Connection - module handling the tcp connection with mpd

VERSION

version 0.9.6

DESCRIPTION

This module will spawn a poe session responsible for low-level communication with mpd. It is written as a pococ-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 POCOCM.

PUBLIC METHODS

spawn( \%params )

This method will create a POE::Component::TCP session responsible for low-level communication with mpd.

It will return the poe id of the session newly created.

You should provide some arguments as a hash reference, where the hash keys are:

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.

The args without default are not supposed to be empty - ie, you will get an error if you don't follow those requirements! Yes, this is a private class, and you're not supposed to use it beyond pococm. :-)

PUBLIC EVENTS ACCEPTED

The following events are accepted from outside this class - but of course restricted to POCOCM (in oo-lingo, they are more protected rather than public).

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 pococm-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
 
 
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.