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); } }
private function get_messages() { // Read messages from session $session = new midcom_core_services_sessioning('midcom_services_uimessages'); if ($session->exists('midcom_services_uimessages_stack')) { // We've got old messages in the session $stored_messages = $session->get('midcom_services_uimessages_stack'); $session->remove('midcom_services_uimessages_stack'); if (!is_array($stored_messages)) { return false; } foreach ($stored_messages as $message) { $id = $this->add($message); $this->messages_from_session[] = $id; } } return $this->messages_from_session; }