
KGS::Listener - a generic base class to listen for kgs messages.

use base KGS::Listener;
sub new {
my $class = shift;
my $self = $class->SUPER::new (@_);
# for non-channel-related listeners:
$self->listen ($self->{conn}, qw(ping req_pic));
# for channel-type listener
$self->listen ($self->{conn}, qw(join_room: part_room: msg_room:));
$self;
}
sub inject_xxx {
# handle msg xxx
}
# KGS::Listener::Room etc. als require this:
sub event_xxx {
# handle synthesized event xxx
}

Please supply a description )
The KGS::Listener family has currently these members:
KGS::Listener base class for everything KGS::Listener::Channel base class for channels (games, rooms) KGS::Listener::Game base class that handles games KGS::Listener::Room base class for rooms and their game lists KGS::Listener::Roomlist base class for the overall room listing KGS::Listener::User base class for user info, chats etc. KGS::Listener::Debug prints all messages that marc doesn't understand
Create a new KGS::Listener project. The channel parameter is optional.
Registers the object to receive callback messages of the named type(s). If $conn is undef, returns immediately. It's safe to call this function repeatedly.
A msgtype is either a packet name like login or msg_room, the string any, which will match any type, or a msgtype postdixed with : (e.g. msg_room:), in which case it will only match the $listener->{channel} channel.
The connection will be stored in $listener->{conn}.
In your own new method you should call $self->listen once with the connection and the msgtypes you want to listen for.
Unregisters the object again.
The main injector callback.. all (listened for) messages end up in this method, which will just dispatch a method with name inject_<msgtype>.
You do not normally have to overwrite this method, but you should provide methods that are being called with names like inject_msg_room etc.
Calls the send method of the connection when in listen state. It does not (yet) supply a default channel id.