NAME

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

SYNOPSIS

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
}

DESCRIPTION

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

METHODS

new [channel => <id>]...

Create a new KGS::Listener project. The channel parameter is optional.

$listener->listen ($conn, [msgtype...])

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.

$listener->unlisten

Unregisters the object again.

$listener->inject ($msg)

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.

$listener->send ($type, %args);

Calls the send method of the connection when in listen state. It does not (yet) supply a default channel id.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 61:

=cut found outside a pod block. Skipping to next block.