[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/daemon/bot/adapter/ -> PhabricatorBaseProtocolAdapter.php (source)

   1  <?php
   2  
   3  /**
   4   * Defines the api for protocol adapters for @{class:PhabricatorBot}
   5   */
   6  abstract class PhabricatorBaseProtocolAdapter {
   7  
   8    private $config;
   9  
  10    public function setConfig($config) {
  11      $this->config = $config;
  12      return $this;
  13    }
  14  
  15    public function getConfig($key, $default = null) {
  16      return idx($this->config, $key, $default);
  17    }
  18  
  19    /**
  20     * Performs any connection logic necessary for the protocol
  21     */
  22    abstract public function connect();
  23  
  24    /**
  25     * Disconnect from the service.
  26     */
  27    public function disconnect() {
  28      return;
  29    }
  30  
  31    /**
  32     * This is the spout for messages coming in from the protocol.
  33     * This will be called in the main event loop of the bot daemon
  34     * So if if doesn't implement some sort of blocking timeout
  35     * (e.g. select-based socket polling), it should at least sleep
  36     * for some period of time in order to not overwhelm the processor.
  37     *
  38     * @param Int $poll_frequency The number of seconds between polls
  39     */
  40    abstract public function getNextMessages($poll_frequency);
  41  
  42    /**
  43     * This is the output mechanism for the protocol.
  44     *
  45     * @param PhabricatorBotMessage $message The message to write
  46     */
  47    abstract public function writeMessage(PhabricatorBotMessage $message);
  48  
  49    /**
  50     * String identifying the service type the adapter provides access to, like
  51     * "irc", "campfire", "flowdock", "hipchat", etc.
  52     */
  53    abstract public function getServiceType();
  54  
  55    /**
  56     * String identifying the service name the adapter is connecting to. This is
  57     * used to distinguish between instances of a service. For example, for IRC,
  58     * this should return the IRC network the client is connecting to.
  59     */
  60    abstract public function getServiceName();
  61  
  62  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1