freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace Phem\Libraries\MessageBus;
use Phem\Environment\ApplicationException;
use Ratchet\WebSocket\Version\RFC6455\Message;
/**
* @author Jakub PetrĹžĂlka <petrzilka@czweb.net>
*/
class CometPusher extends Pusher
{
public function push($message)
{
if (!function_exists("posix_kill"))
{
throw new ApplicationException('Posix support is missing');
}
$username = $message->getToUsr();
if ($username == null)
{
foreach (self::getLoggedUsers() as $user)
{
self::setVar('user.queue.' . $user->getSession()
. '.' . $message->getId(), $message);
}
//$iter = new \APCIterator('user', '/user.pid./');
$iter = \xcache_list(XC_TYPE_VAR, 0)['cache_list'];
foreach ($iter as $item)
{
if (strpos($item["name"], 'user.pid') === false)
{
continue;
}
posix_kill(self::getVar($item['name']), SIGUSR1);
}
}
else
{
foreach (self::getUserSessions($username) as $session)
{
self::setVar('user.queue.' . $session
. '.' . $message->getId(), $message);
$pid = self::getVar('user.pid.' . $session);
posix_kill($pid, SIGUSR1);
}
}
}
}