| 1 | <?php  | 
            ||
| 13 | class Connection extends Stream implements ConnectionInterface  | 
            ||
| 14 | { | 
            ||
| 15 | /**  | 
            ||
| 16 | * @param resource $stream  | 
            ||
| 17 | */  | 
            ||
| 18 | 9 | public function handleData($stream)  | 
            |
| 19 |     { | 
            ||
| 20 | 9 | $data = stream_socket_recvfrom($stream, $this->bufferSize);  | 
            |
| 21 | 9 |         if ('' !== $data && false !== $data) { | 
            |
| 22 | 5 |             $this->emit('data', array($data, $this)); | 
            |
| 23 | }  | 
            ||
| 24 | |||
| 25 | 9 |         if ('' === $data || false === $data || !is_resource($stream) || feof($stream)) { | 
            |
| 26 | 7 | $this->end();  | 
            |
| 27 | }  | 
            ||
| 28 | 9 | }  | 
            |
| 29 | |||
| 30 | 7 | public function handleClose()  | 
            |
| 31 |     { | 
            ||
| 32 | 7 |         if (is_resource($this->stream)) { | 
            |
| 33 | 7 | stream_socket_shutdown($this->stream, STREAM_SHUT_RDWR);  | 
            |
| 34 | 7 | stream_set_blocking($this->stream, false);  | 
            |
| 35 | |||
| 36 | 7 | fclose($this->stream);  | 
            |
| 37 | }  | 
            ||
| 38 | 7 | }  | 
            |
| 39 | |||
| 40 | 1 | public function getRemoteAddress() : string  | 
            |
| 44 | |||
| 45 | 4 | public function parseAddress(string $address) : string  | 
            |
| 49 | }  | 
            ||
| 50 |