PHPDaemon\Core\ShellCommand::write PHP Method

write() public method

Send data to the connection. Note that it just writes to buffer that flushes at every baseloop
public write ( string $data ) : boolean
$data string Data to send
return boolean Success
    public function write($data)
    {
        if (!$this->alive) {
            Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
            return false;
        }
        if (!isset($this->bevWrite)) {
            return false;
        }
        if (!mb_orig_strlen($data)) {
            return true;
        }
        $this->writing = true;
        Daemon::$noError = true;
        if (!$this->bevWrite->write($data) || !Daemon::$noError) {
            $this->close();
            return false;
        }
        return true;
    }

Usage Example

示例#1
0
 /**
  * Called when new piece of request's body is received.
  * @param string $c Piece of request's body.
  * @return void
  */
 public function stdin($c)
 {
     if ($c === '') {
         $this->onWrite($this->proc);
     } else {
         $this->proc->write($c);
     }
 }