SPREE-GATHER(2)                                   SPREE-GATHER(2)

     NAME
          Gatherengine - module interface for pre-assembled groups.

     SYNOPSIS
          implement Gatherengine;

          include "spree.m";
          include "spree/gather.m";
          Clique, Member: import Spree;

          init:               fn(m: Spree, c: ref Clique, argv: list of string, archived: int): string;
          clienttype:    fn(): string;
          maxmembers:    fn(): int;
          propose:       fn(members: array of string): string;
          start:              fn(members: array of ref Member, archived: int);
          command:  fn(member: ref Member, c: string): string;
          archive:       fn();
          readfile:      fn(f: int, offset: big, n: int): array of byte;

     DESCRIPTION
          When implementing a spree(2) engine, it is common to have
          the requirement that a certain number of members are grouped
          together before actually starting the engine.  Spree pro-
          vides no support for this directly; instead the gather mod-
          ule acts as an intermediate layer: engines that wish this
          functionality should implement the Gatherengine interface.
          The gather module also provides facilities for the automatic
          suspension and resumption of players, clique archival, and
          members that watch but do not participate.

          Init is called first, with m, the spree module, and c, the
          new clique.  Argv gives a list of arguments to the engine
          (the first being the name of the engine itself); archived is
          non-zero if the engine has been restored from an archive.
          If init returns a non-nil string, it is taken to describe an
          error, and the engine will be discarded.  Maxmembers should
          return the maximum number of members that the engine can
          accept; clienttype should return the kind of client that is
          expected by the engine (e.g.  cards for a card game engine).

          Propose proposes that a clique consisting of members (the
          names of the proposed members) be started. It returns an
          error string: if this is non-nil, then the clique is not
          started, otherwise the proposed members are accepted into
          the clique, and start is called, where members is the array
          of actual members (corresponding to the members passed to
          propose), and archived is non-zero if the clique is being
          restored from an archive (same as passed to init).

          Once a clique has been successfully started, command is

     Page 1                       Plan 9            (printed 12/22/24)

     SPREE-GATHER(2)                                   SPREE-GATHER(2)

          called when a member sends a command to the engine; member
          has sent the command, and c is the command itself.  Command
          should return a non-nil error string if the command fails.

          When a clique is being archived, archive will be called to
          request the engine to store all its internal state into the
          object hierarchy (this is the moment, for instance, to call
          cardlib->archive).

     SEE ALSO
          spree(2),

     Page 2                       Plan 9            (printed 12/22/24)