Пример #1
0
 private function waitForStreamOnce($stream) : PromiseInterface
 {
     $deferred = new Deferred();
     $this->loop->addWriteStream($stream, function ($stream) use($deferred) {
         $this->loop->removeWriteStream($stream);
         $deferred->resolve($stream);
     });
     return $deferred->promise();
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function write($data)
 {
     if (!$this->writable) {
         return;
     }
     $this->data .= $data;
     if (false === $this->isListening()) {
         $this->setListening(true);
         $this->loop->addWriteStream($this->stream, [$this, 'handleWrite']);
     }
     $belowSoftLimit = strlen($this->data) < $this->getSoftLimit();
     return $belowSoftLimit;
 }