| @@ 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 |
|
| @@ 612-630 (lines=19) @@ | ||
| 609 | * @param string $data Data to send |
|
| 610 | * @return boolean Success |
|
| 611 | */ |
|
| 612 | public function write($data) { |
|
| 613 | if (!$this->alive) { |
|
| 614 | Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')'); |
|
| 615 | return false; |
|
| 616 | } |
|
| 617 | if (!isset($this->bev)) { |
|
| 618 | return false; |
|
| 619 | } |
|
| 620 | if (!strlen($data)) { |
|
| 621 | return true; |
|
| 622 | } |
|
| 623 | $this->writing = true; |
|
| 624 | Daemon::$noError = true; |
|
| 625 | if (!$this->bev->write($data) || !Daemon::$noError) { |
|
| 626 | $this->close(); |
|
| 627 | return false; |
|
| 628 | } |
|
| 629 | return true; |
|
| 630 | } |
|
| 631 | ||
| 632 | /** |
|
| 633 | * Send data and appending \n to connection. Note that it just writes to buffer flushed at every baseloop |
|