isConnected()) { throw new Exception\RuntimeException('You must first open the connection by calling open()'); } $ret = $this->write($message->getPayloadJson()); if ($ret === false) { throw new Exception\RuntimeException('Server is unavailable; please retry later'); } return new MessageResponse($this->read()); } }