| @@ 432-450 (lines=19) @@ | ||
| 429 | * @param string $data Data to send |
|
| 430 | * @return boolean Success |
|
| 431 | */ |
|
| 432 | public function write($data) { |
|
| 433 | if (!$this->alive) { |
|
| 434 | Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')'); |
|
| 435 | return false; |
|
| 436 | } |
|
| 437 | if (!isset($this->bevWrite)) { |
|
| 438 | return false; |
|
| 439 | } |
|
| 440 | if (!strlen($data)) { |
|
| 441 | return true; |
|
| 442 | } |
|
| 443 | $this->writing = true; |
|
| 444 | Daemon::$noError = true; |
|
| 445 | if (!$this->bevWrite->write($data) || !Daemon::$noError) { |
|
| 446 | $this->close(); |
|
| 447 | return false; |
|
| 448 | } |
|
| 449 | return true; |
|
| 450 | } |
|
| 451 | ||
| 452 | /** |
|
| 453 | * Send data and appending \n to connection. Note that it just writes to buffer flushed at every baseloop |
|
| @@ 617-635 (lines=19) @@ | ||
| 614 | * @param string $data Data to send |
|
| 615 | * @return boolean Success |
|
| 616 | */ |
|
| 617 | public function write($data) { |
|
| 618 | if (!$this->alive) { |
|
| 619 | Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')'); |
|
| 620 | return false; |
|
| 621 | } |
|
| 622 | if (!isset($this->bev)) { |
|
| 623 | return false; |
|
| 624 | } |
|
| 625 | if (!strlen($data)) { |
|
| 626 | return true; |
|
| 627 | } |
|
| 628 | $this->writing = true; |
|
| 629 | Daemon::$noError = true; |
|
| 630 | if (!$this->bev->write($data) || !Daemon::$noError) { |
|
| 631 | $this->close(); |
|
| 632 | return false; |
|
| 633 | } |
|
| 634 | return true; |
|
| 635 | } |
|
| 636 | ||
| 637 | /** |
|
| 638 | * Send data and appending \n to connection. Note that it just writes to buffer flushed at every baseloop |
|