jablonka.czprosek.czf

freenet-router

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

 

Line No. Rev Author Line
12simandl<?php
2 
3namespace Phem\Libraries\MessageBus;
4 
5use Phem\Environment\ApplicationException;
6use Ratchet\WebSocket\Version\RFC6455\Message;
7 
8/**
9 * @author Jakub PetrŞílka <petrzilka@czweb.net>
10 */
11class CometPusher extends Pusher
12{
13 
14 public function push($message)
15 {
16 if (!function_exists("posix_kill"))
17 {
18 throw new ApplicationException('Posix support is missing');
19 }
20 
21 $username = $message->getToUsr();
22 if ($username == null)
23 {
24 foreach (self::getLoggedUsers() as $user)
25 {
26 self::setVar('user.queue.' . $user->getSession()
27 . '.' . $message->getId(), $message);
28 }
29 
30 //$iter = new \APCIterator('user', '/user.pid./');
31 $iter = \xcache_list(XC_TYPE_VAR, 0)['cache_list'];
32 foreach ($iter as $item)
33 {
34 if (strpos($item["name"], 'user.pid') === false)
35 {
36 continue;
37 }
38 posix_kill(self::getVar($item['name']), SIGUSR1);
39 }
40 }
41 else
42 {
43 foreach (self::getUserSessions($username) as $session)
44 {
45 self::setVar('user.queue.' . $session
46 . '.' . $message->getId(), $message);
47 $pid = self::getVar('user.pid.' . $session);
48 
49 posix_kill($pid, SIGUSR1);
50 }
51 }
52 }
53 
54}

Powered by WebSVN 2.2.1