Ejemplo n.º 1
0
 /**
  * @param callable $callback
  * @param array $options
  * @throws InvalidArgumentException
  */
 public function __construct($callback, array $options = array())
 {
     parent::__construct($options);
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('You must supply a callback to PayloadHandler');
     }
     $this->callback = $callback;
 }
Ejemplo n.º 2
0
 /**
  * Configure options
  *
  * Options include
  *   - socket_class      => The socket class to use, defaults to ServerSocket
  *   - socket_options    => An array of socket options
  *   - logger            => Closure($message, $priority = 'info'), used
  *                                 for logging
  *
  * @param array $options
  * @return void
  */
 protected function configure(array $options)
 {
     $options = array_merge(array('connection_manager_class' => 'Wrench\\ConnectionManager', 'connection_manager_options' => array()), $options);
     parent::configure($options);
     $this->configureConnectionManager();
     $this->configureLogger();
 }
Ejemplo n.º 3
0
 /**
  * @see Wrench\Util.Configurable::configure()
  */
 protected function configure(array $options)
 {
     $options = array_merge(array('connection_id_secret' => 'asu5gj656h64Da(0crt8pud%^WAYWW$u76dwb', 'connection_id_algo' => 'sha512'), $options);
     parent::configure($options);
 }
Ejemplo n.º 4
0
 /**
  * Configure options
  *
  * @param array $options
  * @return void
  */
 protected function configure(array $options)
 {
     $options = array_merge(array('socket_class' => 'Wrench\\Socket\\ClientSocket', 'on_data_callback' => null), $options);
     parent::configure($options);
 }
Ejemplo n.º 5
0
 /**
  * Configure options
  *
  * Options include
  *   - timeout_socket       => int, seconds, default 5
  *
  * @param array $options
  * @return void
  */
 protected function configure(array $options)
 {
     $options = array_merge(array('timeout_socket' => self::TIMEOUT_SOCKET), $options);
     parent::configure($options);
 }
Ejemplo n.º 6
0
 /**
  * @see Wrench\Socket.Socket::configure()
  *   Options include:
  *     - timeout_select          => int, seconds, default 0
  *     - timeout_select_microsec => int, microseconds (NB: not milli), default: 200000
  */
 protected function configure(array $options)
 {
     $options = array_merge(array('socket_master_class' => 'Wrench\\Socket\\ServerSocket', 'socket_master_options' => array(), 'socket_client_class' => 'Wrench\\Socket\\ServerClientSocket', 'socket_client_options' => array(), 'connection_class' => 'Wrench\\Connection', 'connection_options' => array(), 'timeout_select' => self::TIMEOUT_SELECT, 'timeout_select_microsec' => self::TIMEOUT_SELECT_MICROSEC), $options);
     parent::configure($options);
     $this->configureMasterSocket();
 }
Ejemplo n.º 7
0
 /**
  * @param array $options
  */
 protected function configure(array $options)
 {
     $options = array_merge(array('connections' => 200, 'connections_per_ip' => 5, 'requests_per_minute' => 200), $options);
     parent::configure($options);
     $this->logger = $options->logger;
 }