From 2847f21f8ece215f4cdb570b527c0d26985ef44d Mon Sep 17 00:00:00 2001 From: Derick Ostrenko Date: Sun, 21 Jul 2019 00:05:00 -0500 Subject: [PATCH] changed itemback to broadcast.emit --- diamondsCluster/diamondsCluster.js | 7 ++-- diamondsCluster/public/js/audience.js | 44 +++++++++++++------------- diamondsCluster/public/js/theater.js | 4 +-- diamondsCluster/public/poet/index.html | 10 +++--- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/diamondsCluster/diamondsCluster.js b/diamondsCluster/diamondsCluster.js index e8475db..70d9385 100755 --- a/diamondsCluster/diamondsCluster.js +++ b/diamondsCluster/diamondsCluster.js @@ -284,11 +284,12 @@ if (cluster.isMaster) { console.log("*** Generated Text ***\n", generatedText); // Save generated sentances into redis. if (generatedText) { - console.log("*** TEST ***\n", generatedText); - redisClient.lpush("markov", generatedText); // Send generated sentances to EVERYONE FIXME: Should this only be a few people? - socket.emit('itemback', { phrase: generatedText, color: socket.userColor, sessionName: socket.sessionName }); + + // socket.emit('itemback', { phrase: generatedText, color: socket.userColor, sessionName: socket.sessionName }); + socket.broadcast.emit('itemback', { phrase: generatedText, color: socket.userColor, sessionName: socket.sessionName }); + redisClient.get('controllerID-' + socket.sessionName, function (err, reply) { let controllerID = reply; if (controllerID) { diff --git a/diamondsCluster/public/js/audience.js b/diamondsCluster/public/js/audience.js index a7de27d..7e4feeb 100644 --- a/diamondsCluster/public/js/audience.js +++ b/diamondsCluster/public/js/audience.js @@ -94,7 +94,7 @@ function actOnText() { } -$('.scoreText').click(function(e) { +$('.scoreText').click(function (e) { target = event.target || event.srcElement; if (target.nodeName.toLowerCase() === "span") { @@ -127,7 +127,7 @@ $('.scoreText').click(function(e) { // elements[0].style.backgroundColor = myColor; // } -window.onload = function() { +window.onload = function () { registerWithServer(); joinSession(); } @@ -161,7 +161,7 @@ function putInText(seedPath = "/data/score.txt") { console.log("seedPath", seedPath); xhr.open('GET', seedPath, true); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (this.readyState !== 4) return; if (this.status !== 200) return; var scoreText = document.getElementsByClassName("scoreText")[0]; @@ -187,7 +187,7 @@ function putInText(seedPath = "/data/score.txt") { }; -$(window).resize(function() { +$(window).resize(function () { // document.getElementsByTagName("body")[0].style.borderLeft = "15px solid " + myColor; // console.log("resized"); }); @@ -234,7 +234,7 @@ function joinSession() { // ********************************************************** // Only for the Overlay/intro page -socket.on('registerComplete', function(data) { +socket.on('registerComplete', function (data) { console.log("registerComplete: " + data); user.socketID = data.socketID; localStorage.setItem("socketID", data.socketID); @@ -244,7 +244,7 @@ socket.on('registerComplete', function(data) { } }); -socket.on('setSection', function(data) { +socket.on('setSection', function (data) { // console.log(data); console.log("the section is now: " + data.title); }); @@ -253,8 +253,8 @@ socket.on('setSection', function(data) { // Add Chords, Progression, feedback, comb filtering, shimmer! -socket.on('itemback', function(data) { - console.log("itemback:", data); +socket.on('itemback', function (data) { + console.log("itembackk: ", data); if (data.sessionName == user.sessionName) { var elements = document.getElementsByClassName("gentext")[0]; elements.innerHTML = data.phrase; @@ -264,70 +264,70 @@ socket.on('itemback', function(data) { }); -socket.on('audienceEnable', function(data) { +socket.on('audienceEnable', function (data) { console.log('enabled? ', data); dSound.audienceEnable(data); }); -socket.on('start', function(data) { +socket.on('start', function (data) { console.log("Start: ", data); dSound.speak("So it begins..."); }); -socket.on('excite', function(data) { +socket.on('excite', function (data) { if (generatedTexts.length > 0) { dSound.speak(generatedTexts[generatedTexts.length - 1]); } }); -socket.on('echo', function(data) { +socket.on('echo', function (data) { console.log("Echo: ", data.phrase); dSound.speak(data.phrase); }); -socket.on('kill', function(data) { +socket.on('kill', function (data) { console.log("Kill: ", data); dSound.speak('die'); }); -socket.on('volta', function(data) { +socket.on('volta', function (data) { console.log("Volta: ", data); dSound.playRandomMelody(9, '2n', '16n', 0.15); dSound.speak('Umm, volta, yeah.'); }); -socket.on('end', function(data) { +socket.on('end', function (data) { console.log("End: ", data); dSound.speak('Thank you.'); }); -socket.on('playChord', function(data) { +socket.on('playChord', function (data) { dSound.playChord(data.notes, data.duration); }); -socket.on('sustainChord', function(data) { +socket.on('sustainChord', function (data) { dSound.playChord(data.notes, data.duration); }); -socket.on('triggerBeginning', function(data) { +socket.on('triggerBeginning', function (data) { dSound.playKepler(); }); -socket.on('nextChord', function(data) { +socket.on('nextChord', function (data) { dSound.nextChord(); }); -socket.on('triggerUtopalypse', function(data) { +socket.on('triggerUtopalypse', function (data) { dSound.playUtopalypse(); }); -socket.on('triggerDiamonds', function(data) { +socket.on('triggerDiamonds', function (data) { dSound.playDiamonds(); }); -socket.on('triggerEnding', function(data) { +socket.on('triggerEnding', function (data) { dSound.playEnding(); }); diff --git a/diamondsCluster/public/js/theater.js b/diamondsCluster/public/js/theater.js index 93ec213..7cb8aaa 100644 --- a/diamondsCluster/public/js/theater.js +++ b/diamondsCluster/public/js/theater.js @@ -62,7 +62,7 @@ function joinSession() { // Only for the Overlay/intro page socket.on('registerComplete', function (data) { - console.log("registerComplete: " + data); + console.log("registerComplete: ", data); user.socketID = data.socketID; localStorage.setItem("socketID", data.socketID); if (data.corpus) { @@ -116,7 +116,7 @@ var w1 = 10; socket.on('itemback', function (data) { - console.log("somethingBack", data.sessionName); + console.log("somethingBack", data); if (data.sessionName == user.sessionName) { if (userbars[data.color] > 0) { diff --git a/diamondsCluster/public/poet/index.html b/diamondsCluster/public/poet/index.html index e29770d..bf7b939 100755 --- a/diamondsCluster/public/poet/index.html +++ b/diamondsCluster/public/poet/index.html @@ -85,8 +85,8 @@ // Only for the Overlay/intro page - socket.on('registerComplete', function(data) { - console.log("registerComplete: " + data); + socket.on('registerComplete', function (data) { + console.log("registerComplete: ", data); user.socketID = data.socketID; localStorage.setItem("socketID", data.socketID); if (data.corpus) { @@ -96,7 +96,7 @@ } }); - socket.on('setSection', function(data) { + socket.on('setSection', function (data) { console.log("The section is now: " + data.title); }); @@ -120,7 +120,7 @@ } } - socket.on('itemback', function(data) { + socket.on('itemback', function (data) { console.log("itemback: " + data.sessionName, data.phrase); if (data.sessionName == user.sessionName) { @@ -211,7 +211,7 @@ // xhr.open('GET', '../data/score.txt', true); - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (this.readyState !== 4) return; if (this.status !== 200) return; // or whatever error handling you want document.getElementsByClassName('scoreText')[0].innerHTML = this.responseText;