voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
675 stars 117 forks source link

How can i specify published messages in a loop by connected session info in one realm? #202

Closed WebdevMerlion closed 8 years ago

WebdevMerlion commented 8 years ago

Hi! So, i have one PHP client, that push messages to a router in a loop. Also have a lot of Autobahn (JS) clients thats subscripts on it, which authenticated with wamp-cra.

How can i specified pushed info up on authid? Or this is not possible in one realm?

Tried to start loop up on RPC call, where i can get session info from connected client, but this is not asynch and it publish whole information for all connected clients about all connected clients

On the server side Client:

$onProvide = function($args, $kwargs, $details) use ($loop, $session, $stmt, &$timer){
        $client = $details->authid;

        $timer = $loop->addPeriodicTimer(
            1,
            function () use ($session, $stmt, $client) {
                $counter = getInfo($client, $stmt);
                $session->publish('com.myapp.push', [$counter]);
            }
        );
    };

$session->register('com.myapp.provide', $onProvide, ['disclose_caller' => true]);

To put it simply, i want to split pushed info from the pusher by joined session info. Oublisher and listeners are joined to one realm.

Sorry, if i missed some related issues.

davidwdan commented 8 years ago

You can publish to individual sessions with the publish option 'eligible' => $sessionIds and to individual authIds with '_thruway_eligible_authroles' => $authIds.
_thruway_eligible_authroles only works with the Thruway router.

WebdevMerlion commented 8 years ago

Thanks! I split info exaсtly as i need! But every new connected session start new timer, and it increase interval for all sessions. Is it possible to asynch loop for sessions?

WebdevMerlion commented 8 years ago

Even more, how can i update info, which will be used inside timer callback in a next periodic timer tick? F.e. i collect connected sessions in a RPC, and have a started periodicTimer, so can i get an updated list of sessions in a next timer tick callback?

mbonneau commented 8 years ago

@WebdevMerlion - Did you still need help with this?

WebdevMerlion commented 8 years ago

No, thanks. I got it.