/** * Sends a message to the client * * @param mixed $message Message to send */ public function send($message) { if ($this->state == self::STATE_CLOSED) { throw new Exception('Unable to send message, connection has been closed'); } if (!is_string($message)) { $message = json_encode($message); } $this->server->send($this->socket, $message); }