Exemple #1
0
 public function messageProvider()
 {
     $msgs = array();
     $users = array('foo', 'bar', 'foobar');
     $convId = md5(time());
     for ($i = 0; $i < 20; $i++) {
         $msg = new Message();
         $rand = rand(0, 2);
         $msg->setUser($users[$rand]);
         $msg->setConvid($convId);
         $msg->setMessage('Test Message');
         $msg->setTimestamp($i);
         $msgs[] = $msg;
     }
     $user = new User();
     $user->setConversationId($convId);
     $user->setUser('foo');
     $user->setJoined(5);
     return array(array($msgs, $convId, $user));
 }
Exemple #2
0
 public function execute()
 {
     $command = json_encode(array('type' => 'send_chat_msg', 'data' => array('user' => $this->requestData['user'], 'conv_id' => $this->requestData['conv_id'], 'timestamp' => $this->requestData['timestamp'], 'chat_msg' => $this->requestData['chat_msg'])));
     $this->pushMessageMapper->createForAllUsersInConv($this->requestData['user']['id'], $this->requestData['conv_id'], $command, $this->requestData['user']['id']);
     // All done
     // insert this chatMsg into the messages table
     $message = new Message();
     $message->setConvid($this->requestData['conv_id']);
     $message->setTimestamp($this->requestData['timestamp']);
     $message->setUser($this->requestData['user']['id']);
     $message->setMessage($this->requestData['chat_msg']);
     $this->messageMapper->insert($message);
 }