PHPDaemon\Core\ShellCommand::write PHP 메소드

write() 공개 메소드

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
리턴 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);
     }
 }