[WAMP] callError bugfix
callError accepts `$errorUri` as per the specification It has previously, erroneously, been changed to $topic Now loosely accepts a URI but can be any data structure that can be json'd If it is given a topic, as they're to be URIs according to the spec it will be transformed to a string
This commit is contained in:
parent
002ae9419c
commit
226ec07b02
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user