public function send($message, $receiver) { try { $envelope = new Socket\Envelope($message, $receiver, 0); $envelope->setConnectionId($this->getConnectionId($receiver)); parent::write($envelope); } catch (\Exception $e) { static::logError($e->getMessage()); } }
public function read() { $data = ''; $env_list = array(); while ($chunk = socket_read($this->resource, self::READ_LENGTH)) { $data .= $chunk; } if (!empty($data)) { $data = explode($this->getDelimiter(), $data); foreach ($data as $e) { if (!empty($e)) { $e = Envelope::__fromString($e); $e->setConnectionId($this->id); $env_list[] = $e; } } } return $env_list; }