WAMP Codes
Changed the WAMP codes back into constants. Added the new Welcome constant (not yet implemented)
This commit is contained in:
parent
4372f9a8c3
commit
aceb2c9006
@ -23,8 +23,19 @@ use Ratchet\Application\WAMP\Command\Action\Prefix;
|
|||||||
* | EVENT | 8 | Server-to-Client |
|
* | EVENT | 8 | Server-to-Client |
|
||||||
* +--------------+----+------------------+
|
* +--------------+----+------------------+
|
||||||
* @link http://www.tavendo.de/autobahn/protocol.html
|
* @link http://www.tavendo.de/autobahn/protocol.html
|
||||||
|
* @link https://raw.github.com/oberstet/Autobahn/master/lib/javascript/autobahn.js
|
||||||
*/
|
*/
|
||||||
class App implements WebSocketAppInterface {
|
class App implements WebSocketAppInterface {
|
||||||
|
const MSG_WELCOME = 0;
|
||||||
|
const MSG_PREFIX = 1;
|
||||||
|
const MSG_CALL = 2;
|
||||||
|
const MSG_CALL_RESULT = 3;
|
||||||
|
const MSG_CALL_ERROR = 4;
|
||||||
|
const MSG_SUBSCRIBE = 5;
|
||||||
|
const MSG_UNSUBSCRIBE = 6;
|
||||||
|
const MSG_PUBLISH = 7;
|
||||||
|
const MSG_EVENT = 8;
|
||||||
|
|
||||||
protected $_app;
|
protected $_app;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,11 +92,11 @@ class App implements WebSocketAppInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($json[0]) {
|
switch ($json[0]) {
|
||||||
case 1:
|
case static::MSG_PREFIX:
|
||||||
$ret = $this->addPrefix($from, $json[1], $json[2]);
|
$ret = $this->addPrefix($from, $json[1], $json[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case static::MSG_CALL:
|
||||||
array_shift($json);
|
array_shift($json);
|
||||||
$callID = array_shift($json);
|
$callID = array_shift($json);
|
||||||
$procURI = array_shift($json);
|
$procURI = array_shift($json);
|
||||||
@ -97,15 +108,15 @@ class App implements WebSocketAppInterface {
|
|||||||
$ret = $this->_app->onCall($from, $callID, $procURI, $json);
|
$ret = $this->_app->onCall($from, $callID, $procURI, $json);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case static::MSG_SUBSCRIBE:
|
||||||
$ret = $this->_app->onSubscribe($from, $this->getUri($from, $json[1]));
|
$ret = $this->_app->onSubscribe($from, $this->getUri($from, $json[1]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case static::MSG_UNSUBSCRIBE:
|
||||||
$ret = $this->_app->onUnSubscribe($from, $this->getUri($from, $json[1]));
|
$ret = $this->_app->onUnSubscribe($from, $this->getUri($from, $json[1]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case static::MSG_PUBLISH:
|
||||||
$ret = $this->_app->onPublish($from, $this->getUri($from, $json[1]), $json[2]);
|
$ret = $this->_app->onPublish($from, $this->getUri($from, $json[1]), $json[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet\Application\WAMP\Command\Action;
|
namespace Ratchet\Application\WAMP\Command\Action;
|
||||||
use Ratchet\Resource\Command\Action\SendMessage;
|
use Ratchet\Resource\Command\Action\SendMessage;
|
||||||
|
use Ratchet\Application\WAMP\App as WAMP;
|
||||||
|
|
||||||
class CallError extends SendMessage {
|
class CallError extends SendMessage {
|
||||||
protected $_id;
|
protected $_id;
|
||||||
@ -14,7 +15,7 @@ class CallError extends SendMessage {
|
|||||||
$this->_uri = $uri;
|
$this->_uri = $uri;
|
||||||
$this->_desc = $desc;
|
$this->_desc = $desc;
|
||||||
|
|
||||||
return $this->setMessage(json_encode(array(4, $callId, $uri, $desc)));
|
return $this->setMessage(json_encode(array(WAMP::MSG_CALL_ERROR, $callId, $uri, $desc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId() {
|
public function getId() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet\Application\WAMP\Command\Action;
|
namespace Ratchet\Application\WAMP\Command\Action;
|
||||||
use Ratchet\Resource\Command\Action\SendMessage;
|
use Ratchet\Resource\Command\Action\SendMessage;
|
||||||
|
use Ratchet\Application\WAMP\App as WAMP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -13,7 +14,7 @@ class CallResult extends SendMessage {
|
|||||||
$this->_id = $callId;
|
$this->_id = $callId;
|
||||||
$this->_data = $data;
|
$this->_data = $data;
|
||||||
|
|
||||||
return $this->setMessage(json_encode(array(3, $callId, $data)));
|
return $this->setMessage(json_encode(array(WAMP::MSG_CALL_RESULT, $callId, $data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId() {
|
public function getId() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet\Application\WAMP\Command\Action;
|
namespace Ratchet\Application\WAMP\Command\Action;
|
||||||
use Ratchet\Resource\Command\Action\SendMessage;
|
use Ratchet\Resource\Command\Action\SendMessage;
|
||||||
|
use Ratchet\Application\WAMP\App as WAMP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an event in the context of a topicURI
|
* This is an event in the context of a topicURI
|
||||||
@ -13,6 +14,6 @@ class Event extends SendMessage {
|
|||||||
* @return Event
|
* @return Event
|
||||||
*/
|
*/
|
||||||
public function setEvent($uri, $msg) {
|
public function setEvent($uri, $msg) {
|
||||||
return $this->setMessage(json_encode(array(8, $uri, (string)$msg)));
|
return $this->setMessage(json_encode(array(WAMP::MSG_EVENT, $uri, (string)$msg)));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet\Application\WAMP\Command\Action;
|
namespace Ratchet\Application\WAMP\Command\Action;
|
||||||
use Ratchet\Resource\Command\Action\SendMessage;
|
use Ratchet\Resource\Command\Action\SendMessage;
|
||||||
|
use Ratchet\Application\WAMP\App as WAMP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a curie to uri mapping to the client
|
* Send a curie to uri mapping to the client
|
||||||
@ -20,7 +21,7 @@ class Prefix extends SendMessage {
|
|||||||
$this->_curie = $curie;
|
$this->_curie = $curie;
|
||||||
$this->_uri = $uri;
|
$this->_uri = $uri;
|
||||||
|
|
||||||
return $this->setMessage(json_encode(array(1, $curie, $uri)));
|
return $this->setMessage(json_encode(array(WAMP::MSG_PREFIX, $curie, $uri)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user