Beispiel #1
0
             $result = $dbFunctions->retrieveRooms($username);
             if ($result != false) {
                 $response["error"] = FALSE;
                 $response["chatrooms"] = $result;
                 echo json_encode($response);
             } else {
                 $response["error"] = TRUE;
                 $response["error_msg"] = "No rooms found";
                 echo json_encode($response);
             }
         } else {
             if ($tag == "create_chatRoom") {
                 $roomName = $_POST['roomName'];
                 $username = $_POST['username'];
                 $friendsJobj = json_decode($_POST['friends']);
                 $result = $dbFunctions->addRoom($roomName, $username, $friendsJobj->friends);
                 if ($result != false) {
                     $response["error"] = FALSE;
                     $response["chatRoom"]["roomID"] = $result["roomID"];
                     $response["chatRoom"]["roomName"] = $result["roomName"];
                     $response["success_msg"] = "Room created successfully";
                     echo json_encode($response);
                 } else {
                     $response["error"] = TRUE;
                     $response["error_msg"] = "Failed to create room";
                     echo json_encode($response);
                 }
             }
         }
     }
 }