Skip to content

Commit

Permalink
changed itemback to broadcast.emit
Browse files Browse the repository at this point in the history
  • Loading branch information
fredeerock committed Jul 21, 2019
1 parent 1f742fe commit 2847f21
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
7 changes: 4 additions & 3 deletions diamondsCluster/diamondsCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
44 changes: 22 additions & 22 deletions diamondsCluster/public/js/audience.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function actOnText() {

}

$('.scoreText').click(function(e) {
$('.scoreText').click(function (e) {
target = event.target || event.srcElement;

if (target.nodeName.toLowerCase() === "span") {
Expand Down Expand Up @@ -127,7 +127,7 @@ $('.scoreText').click(function(e) {
// elements[0].style.backgroundColor = myColor;
// }

window.onload = function() {
window.onload = function () {
registerWithServer();
joinSession();
}
Expand Down Expand Up @@ -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];
Expand All @@ -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");
});
Expand Down Expand Up @@ -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);
Expand All @@ -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);
});
Expand All @@ -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;
Expand All @@ -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();
});

Expand Down
4 changes: 2 additions & 2 deletions diamondsCluster/public/js/theater.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions diamondsCluster/public/poet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -96,7 +96,7 @@
}
});

socket.on('setSection', function(data) {
socket.on('setSection', function (data) {
console.log("The section is now: " + data.title);
});

Expand All @@ -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) {

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2847f21

Please sign in to comment.