AnyEvent::IGS - An implementation of the IGS (Internet Go Server) client protocol
package MyGame;
use base AnyEvent::IGS::Game::;
sub kibitz {
my ($self, $user, $msg) = @_;
print "kibitz by $user: $msg\n";
}
package main;
use AnyEvent;
use AnyEvent::IGS;
my $cv = AnyEvent->condvar;
my $igs = AnyEvent::IGS->new;
$igs->connect ("myguesacc");
$igs->reg_cb (
connect_error => sub {
my ($igs, $err) = @_;
warn "connect error: $err\n";
$cv->broadcast;
},
disconnect => sub {
my ($igs, $reason) = @_;
warn "disconnected, reason: $err\n";
$cv->broadcast;
},
logged_on => sub {
$igs->req_observe (120); # just an example...
}
);
$igs->reg_cb (observe_game => sub {
my ($igs, $game) = @_;
my $mygame = MyGame->newm->new (id => $game->{id}, info => $game);
$igs->reg_game ($id => $mygame);
});
$cv->wait;
This module implements the client protocol of the Pandanet Internet Go Server (IGS). (See also http://www.pandanet.co.jp/English/).
This class inherits the event interface of Object::Event, please consult it for further information about how to register callbacks for events documented later in this documentation.
This is the constructor of the main IGS connection object.
The %args hash can be used to set these options:
The $hostname to connect to.
The $portnumber to connect to.
The $username of the account to connect to.
The $password of the account to connect to. Can be undefined,
in which case a guest login will be done.
If given, then as little state as possible will be maintained. The default is to maintain and update a list of games and users, which cna take considerable bandwidth-
If given, disables announcement and use of the AnyEvent-IGS client-to-client protocol. This affects setting of the info stats field.
IGS incrementally updates it's gamelist, but move counts, observs and
teaching games cannot be updated incrementally, so IGS refreshes the full
gamelist roughly every $seconds seconds (default: 59). The gamelist
will not be refreshed while playing a game, however.
IGS incrementally updates it's userlist, but changes in flags etc. will
not be seen that way, so IGS refreshes the full user list roughly every
$seconds seconds (default: 599). The userlist will not be
refreshed while playing a game, however.
The client-id to use to register to the server. The default is
AnyEvent-IGS-$VERSION. If undef, no id will be registered.
This method initiates the connection to the server.
This method sends the command in the $string to the server.
The end of line markers will be appended by this method.
Requests an update of the gamelist for the given game id's, or all games, if no id's were specified.
Returns information from the global game list for the game with
the number $game_id.
A hash reference will be returned which contains following key/value pairs:
id => game id white => name of white player wrank => rank of white player black => name of black player brank => rank of black player move => current move number of the game (might not be up to date!) size => board size handicap => handicap stones komi => komi of the game byo => byo yomi time Fflag => ? Rflag => game type (might one of I, F, or T, or something else?) title => game title (not usually set for most games)
Registers the AnyEvent::IGS::Game object $obj to receive
game-related events. AnyEvent::IGS::Game is the base class of the
object $obj. It documents the methods called by AnyEvent::IGS.
Unregisters game object $obj or all registered objects if a game id is
specified.
You can register with the Object::Event interface to following events:
When we weren't able to connect successfully this event is emitted.
$error is a human readable error string.
Emitted when we successfully logged on. You can start sending commands here.
Emitted when the connection was interrupted. $reason is a
string explaining what might happened.
1; =head1 AUTHOR
Robin Redeker, <elmex@ta-sa.org>
AnyEvent
AnyEvent::IGS::Game
Gtk2::GoBoard
Games::Go::SimpleBoard
Copyright 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.