Example #1
0
function cleanupChannels()
{
    $rc = new Realtime_channel();
    $rc->selectAdd();
    $rc->selectAdd('channel_key');
    $rc->whereAdd('modified < "' . common_sql_date(time() - Realtime_channel::TIMEOUT) . '"');
    if ($rc->find()) {
        $keys = $rc->fetchAll();
        foreach ($keys as $key) {
            $rc = Realtime_channel::staticGet('channel_key', $key);
            if (!empty($rc)) {
                printfv("Deleting realtime channel '{$key}'\n");
                $rc->delete();
            }
        }
    }
}
Example #2
0
 static function fetchChannel($user_id, $action, $arg1, $arg2)
 {
     $channel = new Realtime_channel();
     if (is_null($user_id)) {
         $channel->whereAdd('user_id is null');
     } else {
         $channel->user_id = $user_id;
     }
     $channel->action = $action;
     if (is_null($arg1)) {
         $channel->whereAdd('arg1 is null');
     } else {
         $channel->arg1 = $arg1;
     }
     if (is_null($arg2)) {
         $channel->whereAdd('arg2 is null');
     } else {
         $channel->arg2 = $arg2;
     }
     if ($channel->find(true)) {
         $channel->increment();
         return $channel;
     } else {
         return null;
     }
 }