예제 #1
0
 public function subscribe($userId, $topic)
 {
     // Setting the session id so that if the session times out and the record
     // is removed from
     // the session_data table the deletion can cascade to event descriptions
     try {
         $sub = array("userId" => $userId, "topic" => $topic, "session_id" => AppUtils::getSessionId());
         $this->db->event_subscriptions()->insert($sub);
     } catch (PDOException $e) {
         if ((int) $e->getCode() != 23000) {
             AppUtils::logError($e, __METHOD__);
             throw $e;
         }
     }
 }
예제 #2
0
 /**
  *
  * @see EventServicePDO::subscribe()
  */
 public static function subscribe($userId, $topic)
 {
     try {
         $pdo = new EventServicePDO();
         $pdo->subscribe($userId, $topic, AppUtils::getSessionId());
         AppUtils::sendResponse(array("success" => true, "message" => "User {$userId} subscribed to topic {$topic}"));
     } catch (PDOException $e) {
         AppUtils::logError($e, __METHOD__);
         AppUtils::sendError($e->getCode(), "Error subscribing to events user {$userId} topic {$topic}", $e->getMessage());
     }
 }