Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf1953ddb3 | |||
| 14fd29871b | |||
| 724df64c82 | |||
| de5d36d16c | |||
| 56c42435c8 | |||
| 894dc4693b | |||
| 37714bcdd7 | |||
| 71a4057de7 | |||
| 35fc8dc974 | |||
| 236e1ecf31 | |||
| 8f650e4043 | |||
| 652c5de4f1 | |||
| 0831309ff2 | |||
| 97bb20a2a9 | |||
| a2efd3bab2 | |||
| 08c0902606 | |||
| e761112951 | |||
| 0758f974ec | |||
| 59a11f2ed1 | |||
| 7ccf281074 | |||
| 6a401d6c1b | |||
| d03d5b0fd9 | |||
| 42cf703556 | |||
| 81926e1467 | |||
| be018e5603 | |||
| 1fd1db4e14 | |||
| 17e4d233d2 | |||
| 5319296eb1 | |||
| d7422d3885 | |||
| 5b4fba8dc8 |
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
@@ -6,5 +6,6 @@ To run TheChaseBuzzer yourself, complete the following steps:
|
|||||||
2. Install node.js from https://nodejs.org/en/
|
2. Install node.js from https://nodejs.org/en/
|
||||||
3. Download all project files for TheChaseBuzzer from this github repository
|
3. Download all project files for TheChaseBuzzer from this github repository
|
||||||
4. Open the main folder of TheChaseBuzzer in cmd (this is the folder containing app.js)
|
4. Open the main folder of TheChaseBuzzer in cmd (this is the folder containing app.js)
|
||||||
5. Enter the command: `node app.js`
|
5. Install the node modules using the command: `npm install`
|
||||||
6. You should then be able to connect to the server in a browser by entering your public ip, followed by `:8080`
|
6. Run the app with the command: `node app.js`
|
||||||
|
7. You should then be able to connect to the server in a browser by entering your public ip, followed by `:8080`
|
||||||
@@ -20,8 +20,33 @@ let anyObjections = false;
|
|||||||
const teamsList = ["Players","Chasers"]
|
const teamsList = ["Players","Chasers"]
|
||||||
const teamsScore = [0,0];
|
const teamsScore = [0,0];
|
||||||
let currentTeamNumber = 0;
|
let currentTeamNumber = 0;
|
||||||
|
let sockets = []
|
||||||
|
|
||||||
|
async function resetApp() {
|
||||||
|
console.log("resetting app")
|
||||||
|
io.emit("resetApp")
|
||||||
|
Object.keys(options).forEach(x => delete options[x])
|
||||||
|
userMap.clear()
|
||||||
|
buzzInfo.splice(0, buzzInfo.length)
|
||||||
|
idkList.splice(0, buzzInfo.length)
|
||||||
|
Object.keys(userMap).forEach(x => delete userMap[x])
|
||||||
|
Object.keys(userInfo).forEach(x => delete userInfo[x])
|
||||||
|
anyObjections = false
|
||||||
|
teamsList.splice(0, buzzInfo.length, "Players", "Chasers")
|
||||||
|
teamsScore.splice(0, teamsScore.length, 0, 0)
|
||||||
|
currentTeamNumber = 0
|
||||||
|
|
||||||
|
const oldSockets = sockets
|
||||||
|
sockets = []
|
||||||
|
|
||||||
|
await new Promise(ok => setTimeout(ok, 1000))
|
||||||
|
oldSockets.forEach(x => x.disconnect(true))
|
||||||
|
oldSockets.splice(0, oldSockets.length)
|
||||||
|
}
|
||||||
|
|
||||||
io.on("connection", (socket) => {
|
io.on("connection", (socket) => {
|
||||||
console.log("a user connected");
|
console.log("a user connected");
|
||||||
|
sockets.push(socket)
|
||||||
|
|
||||||
socket.on("disconnect", () => {
|
socket.on("disconnect", () => {
|
||||||
console.log("user disconnected");
|
console.log("user disconnected");
|
||||||
@@ -97,9 +122,15 @@ io.on("connection", (socket) => {
|
|||||||
io.emit("userInfoToClient", userInfo);
|
io.emit("userInfoToClient", userInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//used by the host when they refresh the page.
|
||||||
|
socket.on("refreshUserInfo", () => {
|
||||||
|
io.emit("userInfoToClient", userInfo);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on("unregisterUsers", () => {
|
socket.on("unregisterUsers", () => {
|
||||||
userInfo = new Object();
|
userInfo = new Object();
|
||||||
io.emit("userInfoToClient", userInfo);
|
io.emit("userInfoToClient", userInfo);
|
||||||
|
io.emit("reconnectUsers");
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("objectionToServer", (userName) => {
|
socket.on("objectionToServer", (userName) => {
|
||||||
@@ -135,6 +166,11 @@ app.get("/browserFunctions.js", (request, response) => {
|
|||||||
response.sendFile("/browserFunctions.js", {root: __dirname });
|
response.sendFile("/browserFunctions.js", {root: __dirname });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.post("/reset", (request, response) => {
|
||||||
|
resetApp()
|
||||||
|
response.redirect("/")
|
||||||
|
});
|
||||||
|
|
||||||
//all files in these folders can be accessed with a GET request of the filename
|
//all files in these folders can be accessed with a GET request of the filename
|
||||||
let assetFolders = ["styles","pages","images","images/buzzers","audio","fonts"];
|
let assetFolders = ["styles","pages","images","images/buzzers","audio","fonts"];
|
||||||
assetFolders.forEach((folderName) => {
|
assetFolders.forEach((folderName) => {
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
|
var buzzerCache = new Map();
|
||||||
|
|
||||||
function userInfoToClient(userInfo) {
|
function userInfoToClient(userInfo) {
|
||||||
for (const user in userInfo) {
|
for (const user in userInfo) {
|
||||||
const userId = user.replaceAll(" ","_");
|
re = new RegExp("\\W","g");
|
||||||
|
const userId = user.replaceAll(re,"_");
|
||||||
|
|
||||||
|
|
||||||
|
buzzerCache.set(userInfo[user].buzzerId, new Audio(userInfo[user].buzzerId+".wav"));
|
||||||
|
|
||||||
if ($("#userListPanel").find("#"+userId).length >= 1) {
|
if ($("#userListPanel").find("#"+userId).length >= 1) {
|
||||||
//update buzzer icon of existing user
|
//update buzzer icon of existing user
|
||||||
$("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId",userInfo[user].buzzerId);
|
$("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId",userInfo[user].buzzerId);
|
||||||
@@ -33,7 +40,7 @@ function buzzInfoToClient(buzzInfo, soundOn) {
|
|||||||
$("#firstBuzz").html(buzzInfo[0].userName);
|
$("#firstBuzz").html(buzzInfo[0].userName);
|
||||||
const userId = buzzInfo[0].userName.replaceAll(" ","_");
|
const userId = buzzInfo[0].userName.replaceAll(" ","_");
|
||||||
let buzzerId = $("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId");
|
let buzzerId = $("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId");
|
||||||
let buzzerSound = new Audio(buzzerId+".wav");
|
let buzzerSound = buzzerCache.get(buzzerId);
|
||||||
if (soundOn == true) {
|
if (soundOn == true) {
|
||||||
buzzerSound.play();
|
buzzerSound.play();
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
After Width: | Height: | Size: 204 KiB |
|
After Width: | Height: | Size: 243 KiB |
|
After Width: | Height: | Size: 170 KiB |
|
After Width: | Height: | Size: 309 KiB |
|
After Width: | Height: | Size: 230 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 162 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 44 KiB |