diff --git a/src/Ratchet/Wamp/WampConnection.php b/src/Ratchet/Wamp/WampConnection.php index 8211a3a..83fd084 100644 --- a/src/Ratchet/Wamp/WampConnection.php +++ b/src/Ratchet/Wamp/WampConnection.php @@ -29,24 +29,28 @@ class WampConnection extends AbstractConnectionDecorator { * @param array An array of data to return to the client */ public function callResult($id, array $data = array()) { - $this->send(json_encode(array(WAMP::MSG_CALL_RESULT, $id, $data))); + return $this->send(json_encode(array(WAMP::MSG_CALL_RESULT, $id, $data))); } /** * Respond with an error to a client call * @param string The unique ID given by the client to respond to - * @param string The URI given by the client ot respond to + * @param string The URI given to identify the specific error * @param string A developer-oriented description of the error * @param string|null An optional human readable detail message to send back */ - public function callError($id, $topic, $desc = '', $details = null) { - $data = array(WAMP::MSG_CALL_ERROR, $id, (string)$topic, $desc); + public function callError($id, $errorUri, $desc = '', $details = null) { + if ($errorUri instanceof Topic) { + $errorUri = (string)$errorUri; + } + + $data = array(WAMP::MSG_CALL_ERROR, $id, $errorUri, $desc); if (null !== $details) { $data[] = $details; } - $this->send(json_encode($data)); + return $this->send(json_encode($data)); } /** @@ -54,7 +58,7 @@ class WampConnection extends AbstractConnectionDecorator { * @param mixed Data to send with the event. Anything that is json'able */ public function event($topic, $msg) { - $this->send(json_encode(array(WAMP::MSG_EVENT, (string)$topic, $msg))); + return $this->send(json_encode(array(WAMP::MSG_EVENT, (string)$topic, $msg))); } /** @@ -63,7 +67,8 @@ class WampConnection extends AbstractConnectionDecorator { */ public function prefix($curie, $uri) { $this->WAMP->prefixes[$curie] = (string)$uri; - $this->send(json_encode(array(WAMP::MSG_PREFIX, $curie, (string)$uri))); + + return $this->send(json_encode(array(WAMP::MSG_PREFIX, $curie, (string)$uri))); } /** @@ -80,6 +85,8 @@ class WampConnection extends AbstractConnectionDecorator { */ public function send($data) { $this->getConnection()->send($data); + + return $this; } /**