public function action_messages($route_id, &$data, $args) { $uimessages = $_MIDCOM->serviceloader->load('uimessages'); if (!$uimessages->supports('comet') || !$uimessages->can_view()) { return; } $type = null; $name = null; if (isset($_MIDCOM->dispatcher->get["cometType"])) { $type = $_MIDCOM->dispatcher->get["cometType"]; } if (isset($_MIDCOM->dispatcher->get["cometName"])) { $name = $_MIDCOM->dispatcher->get["cometName"]; } if ($type == null && $name == null) { throw new midcom_exception_notfound("No comet name or type defined"); } if (ob_get_level() == 0) { ob_start(); } while (true) { $messages = ''; if ($uimessages->has_messages()) { $messages = $uimessages->render_as('comet'); } else { $uimessages->add(array('title' => 'Otsikko from comet', 'message' => 'viesti from comet...')); } midcom_core_helpers_comet::pushdata($messages, $type, $name); ob_flush(); flush(); sleep(5); } // $data['messages'] = $messages; }
public function action_echoer($route_id, &$data, $args) { $type = null; $name = null; if (isset($_MIDCOM->dispatcher->get["cometType"])) { $type = $_MIDCOM->dispatcher->get["cometType"]; } if (isset($_MIDCOM->dispatcher->get["cometName"])) { $name = $_MIDCOM->dispatcher->get["cometName"]; } if ($type == null && $name == null) { throw new midcom_exception_notfound("No comet name or type defined"); } // if (! $session->exists("string")) // { // $session->set("string", false); // } if (ob_get_level() == 0) { ob_start(); } $session = new midcom_core_services_sessioning(); $last_push = ''; while (true) { if ($session->exists("string") && $session->get("string") != '') { $last_push = $session->get("string"); $session->remove("string"); midcom_core_helpers_comet::pushdata($last_push, $type, $name); } else { midcom_core_helpers_comet::pushdata('', $type, $name); } //net_nemein_comettest_pusher::pushdata(time(), $type, $name); ob_flush(); flush(); sleep(5); } }