Index


NAME

AnyEvent::IGS - An implementation of the IGS (Internet Go Server) client protocol

SYNOPSIS

   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;

DESCRIPTION

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.

METHODS

$igs = new IGS key => value...

This is the constructor of the main IGS connection object. The %args hash can be used to set these options:

host => $hostname

The $hostname to connect to.

port => $portnumber

The $portnumber to connect to.

user => $username

The $username of the account to connect to.

password => $password

The $password of the account to connect to. Can be undefined, in which case a guest login will be done.

no_state => 1

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-

no_c2c => 1

If given, disables announcement and use of the AnyEvent-IGS client-to-client protocol. This affects setting of the info stats field.

gamelist_refresh => $seconds

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.

userlist_refresh => $seconds

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.

client_id => $string

The client-id to use to register to the server. The default is AnyEvent-IGS-$VERSION. If undef, no id will be registered.

$igs->connect

This method initiates the connection to the server.

$igs->command ($string)

This method sends the command in the $string to the server. The end of line markers will be appended by this method.

$igs->req_game ([$id...])

Requests an update of the gamelist for the given game id's, or all games, if no id's were specified.

game_info ($game_id)

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)

reg_game ($id = $obj)>

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.

unreg_game ($obj_or_id)

Unregisters game object $obj or all registered objects if a game id is specified.

EVENTS

You can register with the Object::Event interface to following events:

connect_error => $error

When we weren't able to connect successfully this event is emitted. $error is a human readable error string.

logged_on

Emitted when we successfully logged on. You can start sending commands here.

disconnect => $reason

Emitted when the connection was interrupted. $reason is a string explaining what might happened.

1; =head1 AUTHOR

Robin Redeker, <elmex@ta-sa.org>

SEE ALSO

AnyEvent

AnyEvent::IGS::Game

Gtk2::GoBoard

Games::Go::SimpleBoard

COPYRIGHT & LICENSE