/**
  * @param string  $url
  * @param int     $port
  * @param string  $authKey
  * @param boolean $debug
  */
 public function __construct($url, $port, $authKey = null, $debug = false)
 {
     if ($debug) {
         $this->debug = true;
     }
     $this->authKey = $authKey;
     $this->driver = new Driver();
     $this->stream = new Stream($url, Connection::PROTOCOL_TCP, $port, $this->driver);
     $this->stream->open();
     $this->stream->setBlockingOff();
     $this->stream->setReadTimeOut(0, (double) 500000);
     $this->stream->setReceiveMethod(new StreamGetLineMethod(1024, Driver::EOL));
     $this->authenticateWithConstructor();
 }
Example #2
0
 /**
  * Return stream of current iterator object. If this object is stream, just return itself.
  *
  * @return Stream
  */
 public function streamify()
 {
     if ($this instanceof Stream) {
         return $this;
     }
     return Stream::from($this);
 }
Example #3
0
 /**
  * Define stream function in Global.
  *
  * @param \Iterator|\IteratorAggregate|array $source
  * @return Stream returns a streaming object.
  */
 function stream($source)
 {
     return Stream::from($source);
 }