*/ class MessageBus implements MessageComponentInterface { protected $clients; public function __construct() { $this->clients = new Collection(); } public function onOpen(ConnectionInterface $conn) { // Store the new connection to send messages to later $this->clients->put($conn->resourceId, $conn); echo "New connection! ({$conn->resourceId})\n"; $client = $this->clients->get($conn->resourceId); //$client->send('{"acceptedConnection":"'.$conn->resourceId.'"}'); return true; } public function onNotify($msg) { foreach ($this->clients as $client) { $client->send($msg); } } public function onMessage(ConnectionInterface $from, $msg) { $msgobj = json_decode($msg); foreach ($this->clients as $client) { $client->send($msg); } } public function onClose(ConnectionInterface $conn) { \Phem\Environment\Application::onConnectionClose($conn->resourceId); // The connection is closed, remove it, as we can no longer send it messages $this->clients->removeKey($conn->resourceId); echo "Connection {$conn->resourceId} has disconnected\n"; } public function onError(ConnectionInterface $conn, Exception $e) { echo "An error has occurred: {$e->getMessage()}\n"; $conn->close(); } } WebSVN - freenet-router - Blame - Rev 2 - /trunk/freenet-router/var/www/freenet-router/Framework/Libraries/MessageBus/MessageBus.php
  jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Libraries/] [MessageBus/] [MessageBus.php] - Blame information for rev 2

 

Line No. Rev Author Line

Powered by WebSVN 2.2.1