示例#1
0
文件: index.php 项目: abbra/midcom
 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);
     }
 }
示例#2
0
文件: midgard.php 项目: abbra/midcom
 /**
  * Store unshown UI messages from the stack to user session.
  */
 public function store()
 {
     if (count($this->message_stack) == 0) {
         // No unshown messages
         return true;
     }
     // We have to be careful what messages to store to session to prevent them
     // from accumulating
     $messages_to_store = array();
     foreach ($this->message_stack as $id => $message) {
         // Check that the messages were not coming from earlier session
         if (!in_array($id, $this->messages_from_session)) {
             $messages_to_store[$id] = $message;
         }
     }
     if (count($messages_to_store) == 0) {
         // We have only messages coming from earlier sessions, and we ditch those
         return true;
     }
     $session = new midcom_core_services_sessioning('midcom_services_uimessages');
     // Check if some other request has added stuff to session as well
     if ($session->exists('midcom_services_uimessages_stack')) {
         $old_stack = $session->get('midcom_services_uimessages_stack');
         $messages_to_store = array_merge($old_stack, $messages_to_store);
     }
     $session->set('midcom_services_uimessages_stack', $messages_to_store);
     $this->message_stack = array();
 }