amazon server setup

This commit is contained in:
Dooho Yi 2018-09-15 19:08:20 +00:00
parent 8715f62ede
commit 6cea3a1cc5
4 changed files with 334 additions and 518 deletions

184
app.js
View file

@ -59,153 +59,12 @@ var io = require('socket.io')(httpServer, {
//express configuration
app.use(express.static('public'));
// //'scroll' status array
// var scroll = {};
// scroll['a'] = {
// value: 0,
// islocked: false
// };
// scroll['b'] = {
// value: 0,
// islocked: false
// };
// scroll['c'] = {
// value: 0,
// islocked: false
// };
// scroll['d'] = {
// value: 0,
// islocked: false
// };
// scroll['e'] = {
// value: 0,
// islocked: false
// };
// scroll['f'] = {
// value: 0,
// islocked: false
// };
// scroll['g'] = {
// value: 0,
// islocked: false
// };
// scroll['h'] = {
// value: 0,
// islocked: false
// };
// //'sound' status array
// var sound_stat = {};
// sound_stat['a'] = {
// id: 0,
// isplaying: false,
// playcount: 0
// };
// sound_stat['b'] = {
// id: 1,
// isplaying: false,
// playcount: 0
// };
// sound_stat['c'] = {
// id: 2,
// isplaying: false,
// playcount: 0
// };
// sound_stat['d'] = {
// id: 3,
// isplaying: false,
// playcount: 0
// };
// sound_stat['e'] = {
// id: 4,
// isplaying: false,
// playcount: 0
// };
// sound_stat['f'] = {
// id: 5,
// isplaying: false,
// playcount: 0
// };
// sound_stat['g'] = {
// id: 6,
// isplaying: false,
// playcount: 0
// };
// sound_stat['h'] = {
// id: 7,
// isplaying: false,
// playcount: 0
// };
//socket.io events
io.on('connection', function(socket) {
//entry log.
console.log('someone connected.');
//let this new member be up-to-date immediately
// Object.keys(scroll).forEach(function(key) { // ES6 --> https://stackoverflow.com/a/5737192
// socket.emit('scroll', {
// key: key,
// data: scroll[key]
// });
// });
// //on 'scroll' --> relay the msg. to everyone except sender
// socket.on('scroll-get', function(key, fn) {
// console.log('investigating...');
// console.log(key);
// if (scroll[key].islocked == false) {
// fn(true);
// scroll[key].islocked = true;
// } else if (scroll[key].islocked == true) {
// fn(false);
// }
// });
// socket.on('lock-all', function(msg) {
// if (msg.action == 'close') {
// console.log('lock-all');
// Object.keys(scroll).forEach(function(key) {
// console.log(scroll[key].islocked);
// scroll[key].islocked = true;
// console.log(scroll[key].islocked);
// socket.broadcast.emit('scroll', {
// key: key,
// data: scroll[key]
// });
// });
// } else if (msg.action == 'open') {
// console.log('release-all');
// Object.keys(scroll).forEach(function(key) {
// console.log(scroll[key].islocked);
// scroll[key].islocked = false;
// console.log(scroll[key].islocked);
// socket.broadcast.emit('scroll', {
// key: key,
// data: scroll[key]
// });
// });
// }
// })
// //on 'scroll' --> relay the msg. to everyone except sender
// socket.on('scroll', function(msg) {
// //update server's scroll database
// scroll[msg.key].value = msg.data.value;
// scroll[msg.key].islocked = msg.data.islocked;
// //relay the message to everybody except sender
// socket.broadcast.emit('scroll', msg);
// // //relay the message to everybody INCLUDING sender
// // io.emit('scroll', msg);
// //DEBUG
// //console.log('scroll :');
// console.log(msg);
// });
//on 'sound' --> relay the message to everybody INCLUDING sender
// var soundactive = false;
socket.on('sound', function(sound) {
@ -219,28 +78,6 @@ io.on('connection', function(socket) {
console.log('sound.group :' + sound.group);
});
// //on 'voice'
// socket.on('voice', function(voice) {
// //relay the message to everybody INCLUDING sender // TODO: actually only sound server is listening...
// io.emit('voice', voice);
// //DEBUG
// console.log('voice.id :' + voice.id);
// console.log('voice.key :' + voice.key);
// //{name: voice_selected, key: this._idx}
// })
// //on 'page' --> relay the message to everybody INCLUDING sender
// socket.on('page', function(page) {
// //relay the message to everybody INCLUDING sender
// io.emit('page', page);
// //DEBUG
// console.log('page.name :' + page.name);
// });
//on 'clap' --> relay the message to everybody INCLUDING sender
socket.on('clap', function(clap) {
@ -253,29 +90,8 @@ io.on('connection', function(socket) {
//on 'disconnect'
socket.on('disconnect', function() {
//
// if (soundactive == true) {
// soundactive = false;
// if (sound_stat[sound.name].playcount > 0) {
// sound_stat[sound.name].playcount--;
// }
// if (sound_stat[sound.name].isplaying == true) {
// sound_stat[sound.name].isplaying = false;
// //emit stop
// //relay the message to everybody INCLUDING sender -- but actually only 'receiver.js' is listening 'sound_ctrl' msg.
// io.emit('sound_ctrl', {
// id: sound_stat[sound.name].id,
// action: 0
// });
// }
// }
console.log('someone disconnected.');
//NOTE, TODO, BUG:
// --> disconnection one's 'locked' keys must be released!
// otherwise, nobody can use it! (even the one who locked it, when returned.)
//
// (but, then server firstly should also remember 'who' locked 'which' key...)
});
});

658
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -226,8 +226,8 @@ $(document).ready(function() {
var top = new Layer(); // new Layer() will be automatically activated at the moment.
//networking - socket.io
var socket = io('http://192.168.1.105:8080');
//var socket = io('https://choir.run');
//var socket = io('http://192.168.1.105:8080');
var socket = io('http://choir.run:8080');
//net. connection marker
var netstat = new Path.Circle({

View file

@ -226,8 +226,8 @@ $(document).ready(function() {
var top = new Layer(); // new Layer() will be automatically activated at the moment.
//networking - socket.io
var socket = io('http://192.168.1.105:8080');
//var socket = io('https://choir.run');
//var socket = io('http://192.168.1.105:8080');
var socket = io('http://choir.run:8080');
//net. connection marker
var netstat = new Path.Circle({