php - How does Ratchet (socketo.me) broadcast to users subricbed to a certain topic? -


i have been following directions on website socketo.me ratchet, has been fine far. interested in broadcasting topics users subscribed it, , not everyone.

this code given below, , here on website confusing me.

<?php use ratchet\connectioninterface conn;  /**  * when user publishes topic clients have subscribed  * topic receive message/event publisher  */ class basicpubsub implements ratchet\wamp\wampserverinterface {     public function onpublish(conn $conn, $topic, $event, array $exclude, array $eligible) {         $topic->broadcast($event);     }      public function oncall(conn $conn, $id, $topic, array $params) {         $conn->callerror($id, $topic, 'rpc not supported on demo');     }      // no need anything, since wampserver adds , removes subscribers topics automatically     public function onsubscribe(conn $conn, $topic) {}     public function onunsubscribe(conn $conn, $topic) {}      public function onopen(conn $conn) {}     public function onclose(conn $conn) {}     public function onerror(conn $conn, \exception $e) {} } 

this information below on website interpreting should integrated public function onpublish.

events triggered component:

onpublish (connectioninterface $conn, topic $topic, string $event) - user publishes data $topic. should in return event command connections have subscribed $topic

wamp:

(string $sessionid) - unique id given client

(array $subscriptions) - collection of topics client has subscribed

shouldn't code along lines of this

class basicpubsub implements ratchet\wamp\wampserverinterface {     public function onpublish(conn $conn, $topic, $event, $sessionid, array $subscriptions, array $exclude, array $eligible) {     $topic->broadcast($subscriptions);     } /** rest of code here */ } 

clearly $subscriptions populated sql query retrieve topics user has subscribed based on thier $sessionid, , $topic->broadcast($subscriptions); broadcast topic individual users subscribed. not see tutorial doing this, interpretation different. need help!!!


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -