Address PR comments

This commit is contained in:
Romain Neutron
2014-02-14 16:19:32 +01:00
parent c0b152d73a
commit ffab51235a
8 changed files with 34 additions and 14 deletions

View File

@@ -39,14 +39,14 @@ main:
host: 127.0.0.1
port: 6660
linger: 500
publisher:
protocol: tcp
host: 127.0.0.1
port: 13598
websocket-server:
host: local.phrasea
port: 9090
ip: 0.0.0.0
subscriber:
protocol: tcp
host: 127.0.0.1
port: 13598
session:
type: 'file'
options: []

View File

@@ -21,8 +21,7 @@ class WebsocketServer extends Command
{
parent::__construct($name);
$this
->setDescription("Runs the websocket server");
$this->setDescription("Runs the websocket server");
}
public function doExecute(InputInterface $input, OutputInterface $output)

View File

@@ -34,7 +34,7 @@ class WebsocketServerServiceProvider implements ServiceProviderInterface
'protocol' => 'tcp',
'host' => '127.0.0.1',
'port' => 13598,
], $app['conf']->get(['main', 'task-manager', 'publisher'], []));
], $app['conf']->get(['main', 'websocket-server', 'subscriber'], []));
});
$app['ws.task-manager.broadcaster'] = $app->share(function (Application $app) {

View File

@@ -27,18 +27,27 @@ class PhraseanetWampServer implements WampServerInterface
$this->manager = $manager;
}
/**
* {@inheritdoc}
*/
public function onPublish(Conn $conn, $topic, $event, array $exclude, array $eligible)
{
$this->logger->error(sprintf('Publishing on topic %s', $topic->getId()), array('event' => $event, 'topic' => $topic));
$topic->broadcast($event);
}
/**
* {@inheritdoc}
*/
public function onCall(Conn $conn, $id, $topic, array $params)
{
$this->logger->error(sprintf('Received RPC call on topic %s', $topic->getId()), array('topic' => $topic));
$conn->callError($id, $topic, 'RPC not supported on this demo');
}
/**
* {@inheritdoc}
*/
public function onSubscribe(Conn $conn, $topic)
{
if ($this->manager->subscribe($conn, $topic)) {
@@ -48,24 +57,36 @@ class PhraseanetWampServer implements WampServerInterface
}
}
/**
* {@inheritdoc}
*/
public function onUnSubscribe(Conn $conn, $topic)
{
$this->logger->debug(sprintf('Unsubscription received on topic %s', $topic->getId()), array('topic' => $topic));
$this->manager->unsubscribe($conn, $topic);
}
/**
* {@inheritdoc}
*/
public function onOpen(Conn $conn)
{
$this->logger->debug('[WS] Connection request accepted');
$this->manager->openConnection($conn);
}
/**
* {@inheritdoc}
*/
public function onClose(Conn $conn)
{
$this->logger->debug('[WS] Connection closed');
$this->manager->closeConnection($conn);
}
/**
* {@inheritdoc}
*/
public function onError(Conn $conn, \Exception $e)
{
$this->logger->error('[WS] Connection error', ['exception' => $e]);

View File

@@ -16,7 +16,7 @@ use Alchemy\Phrasea\Websocket\Topics\TopicsManager;
interface PluginInterface
{
/**
* Attaches a Plugn to the TopicsManager
* Attaches a Plugin to the TopicsManager
*
* @param TopicsManager $manager
*/

View File

@@ -69,7 +69,7 @@ class patch_390alpha11a implements patchInterface
'port' => 6660,
'linger' => 500,
]);
$app['conf']->set(['main', 'task-manager', 'publisher'], [
$app['conf']->set(['main', 'websocket-server', 'subscriber'], [
'protocol' => 'tcp',
'host' => '127.0.0.1',
'port' => 13598,

View File

@@ -39,14 +39,14 @@ main:
host: 127.0.0.1
port: 6660
linger: 500
publisher:
protocol: tcp
host: 127.0.0.1
port: 13598
websocket-server:
host: local.phrasea
port: 9090
ip: 0.0.0.0
subscriber:
protocol: tcp
host: 127.0.0.1
port: 13598
session:
type: 'file'
options: []

View File

@@ -105,7 +105,7 @@ class SetupTest extends \PhraseanetWebTestCase
->disableOriginalConstructor()
->getMock();
$user->expects($this->exactly(2))
$user->expects($this->exactly(1))
->method('get_id')
->will($this->returnValue(self::$DI['user']->get_id()));