Example #1
0
 public function onAdminMessage(IWebSocketConnection $user, IWebSocketMessage $msg)
 {
     $this->say("[AJXP] Admin message received!");
     // Echo
     // $user->sendMessage($msg);
     $data = unserialize($msg->getData());
     $repoId = $data["REPO_ID"];
     $userId = isset($data["USER_ID"]) ? $data["USER_ID"] : false;
     $userGroupPath = isset($data["GROUP_PATH"]) ? $data["GROUP_PATH"] : false;
     $msg->setData($data["CONTENT"]);
     foreach ($this->getConnections() as $conn) {
         if ($conn == $user) {
             continue;
         }
         if ($repoId != "AJXP_REPO_SCOPE_ALL" && (!isset($conn->currentRepository) || $conn->currentRepository != $repoId)) {
             $this->say("Skipping, not the same repository");
             continue;
         }
         if ($userId !== false && $conn->ajxpId != $userId) {
             $this->say("Skipping, not the same userId");
             continue;
         }
         if ($userGroupPath != false && (!isset($conn->ajxpGroupPath) || $conn->ajxpGroupPath != $userGroupPath)) {
             $this->say("Skipping, not the same groupPath");
             continue;
         }
         $this->say("Should dispatch to user " . $conn->ajxpId);
         $conn->sendMessage($msg);
     }
     //$frame = WebSocketFrame::create(WebSocketOpcode::PongFrame);
     //$user->sendFrame($frame);
 }
 public function onMessage(IWebSocketConnection $user, IWebSocketMessage $msg)
 {
     $msg->setData("Logging this: " . $msg->getData());
     $this->say("[DEMO] {$user->getId()} says '{$msg->getData()}'.  ");
 }