Beispiel #1
0
 /**
  * Retrieve singleton instance
  *
  * @return InstantMessage_Broker
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * Renders messages
  * @param array $messages
  * @return string
  */
 public function renderMessages(array $messages)
 {
     $messagesBroker = InstantMessage_Broker::getInstance();
     $messagesBroker->setMessages($messages);
     return $messagesBroker->render();
 }
 public function ajaximessageAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $substitution = array(array('name' => 'Alex', 'text' => 'Test message from user 1'), array('name' => 'Bill', 'text' => 'Test message from user 2'), array('name' => 'Jack', 'text' => 'Hello world'));
     shuffle($substitution);
     for ($i = 0; $i < rand(0, 3); $i++) {
         unset($substitution[$i]);
     }
     $messages = InstantMessage_Broker::getInstance();
     foreach ($substitution as $values) {
         $messages->addMessage('hello', $values);
     }
     echo $this->_helper->json(array('messages' => $messages->render()), true);
 }