{"action":"closed","issue":{"url":"https://api.github.com/repos/voryx/Thruway/issues/96","labels_url":"https://api.github.com/repos/voryx/Thruway/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/voryx/Thruway/issues/96/comments","events_url":"https://api.github.com/repos/voryx/Thruway/issues/96/events","html_url":"https://github.com/voryx/Thruway/issues/96","id":72654301,"number":96,"title":"Ratchet to Thruway conversion","user":{"login":"xtrasmal","id":1174877,"avatar_url":"https://avatars.githubusercontent.com/u/1174877?v=3","gravatar_id":"","url":"https://api.github.com/users/xtrasmal","html_url":"https://github.com/xtrasmal","followers_url":"https://api.github.com/users/xtrasmal/followers","following_url":"https://api.github.com/users/xtrasmal/following{/other_user}","gists_url":"https://api.github.com/users/xtrasmal/gists{/gist_id}","starred_url":"https://api.github.com/users/xtrasmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xtrasmal/subscriptions","organizations_url":"https://api.github.com/users/xtrasmal/orgs","repos_url":"https://api.github.com/users/xtrasmal/repos","events_url":"https://api.github.com/users/xtrasmal/events{/privacy}","received_events_url":"https://api.github.com/users/xtrasmal/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-05-02T14:34:56Z","updated_at":"2015-07-15T14:53:32Z","closed_at":"2015-07-15T14:53:32Z","body":"Hi there,\r\n\r\nThe code below is what I use from the Ratchet website: http://socketo.me/docs/push\r\nI've got it in a console command in my favorite framework and run it.\r\nAfter that I can connect, publish and subscribe.\r\n\r\nRatchet has a very clear website that get's you on your way pretty fast.\r\n\r\nBut I've learned that Ratchet uses WAMP v1 and Thruway can help me up and running with WAMP v2 so I can use the latest Autobahn version and the angular-wamp router.\r\n \r\nCould you please explain to me how I can get Thruway set up in the same way I've got Ratchet set up?\r\nI'd like to start everything from one command.\r\n\r\n\r\nPushServerCommand.php\r\n\r\n```php\r\n\r\n    /**\r\n     * Execute the console command.\r\n     *\r\n     * @return mixed\r\n     */\r\n    public function fire()\r\n    {\r\n        $loop   = EventloopFactory::create();\r\n        $pusher = new Pusher;\r\n\r\n        // Listen for the web server to make a ZeroMQ push after an ajax request\r\n        $context = new Context($loop);\r\n        $pull = $context->getSocket(\\ZMQ::SOCKET_PULL);\r\n\r\n        $pull->bind('tcp://127.0.0.1:5555'); // Binding to 127.0.0.1 means the only client that can connect is itself\r\n        $pull->on('message', [$pusher, 'onBlogEntry']);\r\n\r\n        // Set up our WebSocket server for clients wanting real-time updates\r\n        $webSock = new Server($loop);\r\n        $webSock->listen(7474, '0.0.0.0'); // Binding to 0.0.0.0 means remotes can connect\r\n        $webServer = new IoServer(\r\n            new HttpServer(\r\n                new WsServer(\r\n                    new WampServer(\r\n                        $pusher\r\n                    )\r\n                )\r\n            ),\r\n            $webSock\r\n        );\r\n\r\n        $loop->run();\r\n\r\n    }\r\n\r\n```\r\nPusher.php\r\n\r\n```php\r\n\r\nclass Pusher implements WampServerInterface {\r\n    /**\r\n     * A lookup of all the topics clients have subscribed to\r\n     */\r\n    protected $subscribedTopics = array();\r\n\r\n    public function onSubscribe(ConnectionInterface $conn, $topic) {\r\n        $this->subscribedTopics[$topic->getId()] = $topic;\r\n    }\r\n\r\n    /**\r\n     * @param string JSON'ified string we'll receive from ZeroMQ\r\n     */\r\n    public function onBlogEntry($entry) {\r\n        $entryData = json_decode($entry, true);\r\n\r\n        // If the lookup topic object isn't set there is no one to publish to\r\n        if (!array_key_exists($entryData['category'], $this->subscribedTopics)) {\r\n            return;\r\n        }\r\n\r\n        $topic = $this->subscribedTopics[$entryData['category']];\r\n\r\n        // re-send the data to all the clients subscribed to that category\r\n        $topic->broadcast($entryData);\r\n    }\r\n\r\n    /* The rest of our methods were as they were, omitted from docs to save space */\r\n}\r\n\r\n```\r\n\r\nThank you a lot."}}