public function stream_write($data)
 {
     $bytesToSend = strlen($data);
     $result = parent::stream_write($data);
     while ($result < $bytesToSend && !$this->stream_eof()) {
         $dataLeft = substr($data, $result);
         $result += parent::stream_write($dataLeft);
     }
     return $result;
 }
 public function stream_write($data)
 {
     $result = parent::stream_write($data);
     if (is_callable($this->writeCallback)) {
         call_user_func($this->writeCallback, $data);
     }
     return $result;
 }