Skip to content

Commit

Permalink
added logic for 'notifications across controllers'
Browse files Browse the repository at this point in the history
  • Loading branch information
Orion1 committed Oct 26, 2014
1 parent a877ba6 commit 11a7723
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/libs/runeaudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -2625,30 +2625,34 @@ function deleteRadio($mpd,$redis,$data)

function ui_notify($title = null, $text, $type = null, $permanotice = null)
{
if (is_object($permanotice)) {
$output = array('permanotice' => $permanotice->name, 'permaremove' => $permanotice->name);
if ($title === 'raw') {
ui_render('notify', $text);
} else {
if (isset($permanotice)) {
$output = array('title' => $title, 'text' => $text, 'type' => $type, 'permanotice' => $permanotice);
if (is_object($permanotice)) {
$output = array('permanotice' => $permanotice->name, 'permaremove' => $permanotice->name);
} else {
$output = array('title' => $title, 'text' => $text, 'type' => $type);
if (isset($permanotice)) {
$output = array('title' => $title, 'text' => $text, 'permanotice' => $permanotice);
} else {
$output = array('title' => $title, 'text' => $text);
}
}
ui_render('notify', json_encode($output));
}
ui_render('notify', json_encode($output));
}

function ui_notify_async($title = null, $text, $type = null, $permanotice = null)
{
if ($title === 'Kernel switch') {
$output = array('title' => $title, 'text' => $text, 'type' => 'kernelswitch', 'btntext' => 'Reboot now');
$output = array('title' => $title, 'text' => $text, 'custom' => 'kernelswitch');
} else {
if (is_object($permanotice)) {
$output = array('permanotice' => $permanotice->name, 'permaremove' => $permanotice->name);
} else {
if (isset($permanotice)) {
$output = array('title' => $title, 'text' => $text, 'type' => $type, 'permanotice' => $permanotice);
$output = array('title' => $title, 'text' => $text, 'permanotice' => $permanotice);
} else {
$output = array('title' => $title, 'text' => $text, 'type' => $type);
$output = array('title' => $title, 'text' => $text);
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions command/rune_SY_wrk
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,16 @@ $redis->pconnect('/tmp/redis.sock');
sysCmd('systemctl restart '.$job->args);
$redis->sRem('w_lock', $jobID);
break;
case 'ui_notify':
runelog('wrk_SY: ', $job->wrkcmd);
runelog('ui_notify (raw)', $job->args);
usleep(250000);
// send notify to RuneUI
foreach ($job->args as $raw_notification) {
ui_notify('raw', $raw_notification);
}
$redis->sRem('w_lock', $jobID);
break;
} // end switch
// delete processed job from the w_queue
$redis->hDel('w_queue', $jobID);
Expand Down
5 changes: 5 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
// close SPOP connection
closeSpopSocket($spop);
}
// notifications
$notifications = $redis->hGetAll('notifications');
if ($notifications !== '') {
wrk_control($redis, 'newjob', $data = array('wrkcmd' => 'ui_notify', 'args' => $notifications));
}
// close Redis connection
// $redis->close();
// close session
Expand Down

0 comments on commit 11a7723

Please sign in to comment.