Esempio n. 1
0
 public function newMessage($user_id, $user_pseudo, $room_id, $message)
 {
     $user_id = (int) $user_id;
     $room_id = (int) $room_id;
     $this->required('newMessage', $user_id, $room_id, $message);
     if (!$this->getRoom()->isInRoom($user_id, $room_id)) {
         $this->error(null, 'You\'re not in this room');
     }
     $room_user_device_ids = $this->getUser()->getMobileIdByRoom($room_id, $user_id);
     $data = array('type' => 'new_message', 'date' => date('H:i:s Y-m-d'), 'from_user' => $user_pseudo, 'room_id' => $room_id);
     // Send message with GCM
     $response = GCM::make($room_user_device_ids, $message, $data);
     $this->data($response);
     return $this->response();
 }
 public function push($type, $user_ids)
 {
     $users_device_ids = $this->getUser()->getMobileIdByUserId($user_ids);
     $data = array('type' => $type, 'date' => date('H:i:s Y-m-d'));
     switch ($type) {
         case 'dashboard_refresh':
             $message = '';
             break;
     }
     // Send message with GCM
     GCM::make($users_device_ids, $message, $data);
 }
Esempio n. 3
0
 /**
  * Make a new GCM object and send it.
  *
  * @param array $devices Array of device ids
  * @param string $message the message to send
  * @param array $data Array of data to accompany the message
  *
  * @return bool
  */
 public static function make($devices, $message, $data)
 {
     $gcm = new GCM();
     $gcm->setDevices($devices);
     $response = $gcm->send($message, $data);
     Log::info(json_encode($response));
     return $response;
 }