mirror of https://github.com/calzoneman/sync.git
Finish refactoring
This commit is contained in:
parent
f4019e8b83
commit
7e9907ebdc
1010
channel-new.js
1010
channel-new.js
File diff suppressed because it is too large
Load Diff
1301
channel.js
1301
channel.js
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,7 @@ var mysql = require("mysql-libmysqlclient");
|
||||||
var Config = require("./config.js");
|
var Config = require("./config.js");
|
||||||
var Logger = require("./logger.js");
|
var Logger = require("./logger.js");
|
||||||
var Rank = require("./rank.js");
|
var Rank = require("./rank.js");
|
||||||
|
var Media = require("./media.js").Media;
|
||||||
|
|
||||||
var initialized = false;
|
var initialized = false;
|
||||||
|
|
||||||
|
@ -84,6 +85,9 @@ exports.loadChannel = function(chan) {
|
||||||
Logger.syslog.log("Channel " + chan.name + " is unregistered.");
|
Logger.syslog.log("Channel " + chan.name + " is unregistered.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if(rows[0].name != chan.name) {
|
||||||
|
chan.name = rows[0].name;
|
||||||
|
}
|
||||||
chan.registered = true;
|
chan.registered = true;
|
||||||
|
|
||||||
// Load library
|
// Load library
|
||||||
|
@ -229,7 +233,7 @@ exports.cacheMedia = function(channame, media) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.addChannelBan(channame, actor, receiver) {
|
exports.addChannelBan = function(channame, actor, receiver) {
|
||||||
var db = exports.getConnection();
|
var db = exports.getConnection();
|
||||||
if(!db) {
|
if(!db) {
|
||||||
Logger.errlog.log("exports.addChannelBan: DB connection failed");
|
Logger.errlog.log("exports.addChannelBan: DB connection failed");
|
||||||
|
@ -245,7 +249,7 @@ exports.addChannelBan(channame, actor, receiver) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.removeChannelBan(channame, ip) {
|
exports.removeChannelBan = function(channame, ip) {
|
||||||
var db = exports.getConnection();
|
var db = exports.getConnection();
|
||||||
if(!db) {
|
if(!db) {
|
||||||
Logger.errlog.log("exports.removeChannelBan: DB connection failed");
|
Logger.errlog.log("exports.removeChannelBan: DB connection failed");
|
||||||
|
|
3
poll.js
3
poll.js
|
@ -25,16 +25,13 @@ Poll.prototype.vote = function(ip, option) {
|
||||||
this.votes[ip] = option;
|
this.votes[ip] = option;
|
||||||
this.counts[option]++;
|
this.counts[option]++;
|
||||||
}
|
}
|
||||||
console.log(this.votes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Poll.prototype.unvote = function(ip) {
|
Poll.prototype.unvote = function(ip) {
|
||||||
console.log('unvote ' + ip + this.votes[ip]);
|
|
||||||
if(ip in this.votes && this.votes[ip] != null) {
|
if(ip in this.votes && this.votes[ip] != null) {
|
||||||
this.counts[this.votes[ip]]--;
|
this.counts[this.votes[ip]]--;
|
||||||
this.votes[ip] = null;
|
this.votes[ip] = null;
|
||||||
}
|
}
|
||||||
console.log(this.votes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Poll.prototype.packUpdate = function() {
|
Poll.prototype.packUpdate = function() {
|
||||||
|
|
24
server.js
24
server.js
|
@ -9,6 +9,9 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const VERSION = "1.0.0";
|
||||||
|
console.log("Starting CyTube v" + VERSION);
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var Logger = require("./logger.js");
|
var Logger = require("./logger.js");
|
||||||
var Config = require("./config.js");
|
var Config = require("./config.js");
|
||||||
|
@ -45,6 +48,7 @@ exports.io.sockets.on("connection", function(socket) {
|
||||||
Logger.syslog.log("Accepted connection from /" + user.ip);
|
Logger.syslog.log("Accepted connection from /" + user.ip);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
process.on("uncaughtException", function(err) {
|
process.on("uncaughtException", function(err) {
|
||||||
Logger.errlog.log("[SEVERE] Uncaught Exception: " + err);
|
Logger.errlog.log("[SEVERE] Uncaught Exception: " + err);
|
||||||
});
|
});
|
||||||
|
@ -52,26 +56,12 @@ process.on("uncaughtException", function(err) {
|
||||||
process.on("exit", shutdown);
|
process.on("exit", shutdown);
|
||||||
process.on("SIGINT", shutdown);
|
process.on("SIGINT", shutdown);
|
||||||
|
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
Logger.syslog.log("Unloading channels...");
|
Logger.syslog.log("Unloading channels...");
|
||||||
for(var name in exports.channels) {
|
for(var name in exports.channels) {
|
||||||
var chan = exports.channels[name];
|
if(exports.channels[name].registered)
|
||||||
var filts = new Array(chan.filters.length);
|
exports.channels[name].saveDump();
|
||||||
for(var i = 0; i < chan.filters.length; i++) {
|
|
||||||
filts[i] = [chan.filters[i][0].source,
|
|
||||||
chan.filters[i][1],
|
|
||||||
chan.filters[i][2]];
|
|
||||||
}
|
|
||||||
var dump = {
|
|
||||||
currentPosition: chan.currentPosition,
|
|
||||||
queue: chan.queue,
|
|
||||||
opts: chan.opts,
|
|
||||||
filters: filts,
|
|
||||||
motd: chan.motd
|
|
||||||
};
|
|
||||||
var text = JSON.stringify(dump);
|
|
||||||
fs.writeFileSync("chandump/" + name, text);
|
|
||||||
chan.logger.flush();
|
|
||||||
}
|
}
|
||||||
Logger.syslog.log("Shutting Down");
|
Logger.syslog.log("Shutting Down");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|
4
user.js
4
user.js
|
@ -133,7 +133,7 @@ User.prototype.initCallbacks = function() {
|
||||||
|
|
||||||
this.socket.on("playNext", function() {
|
this.socket.on("playNext", function() {
|
||||||
if(this.channel != null) {
|
if(this.channel != null) {
|
||||||
this.channel.tryPlayNext(this, data);
|
this.channel.tryPlayNext(this);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ User.prototype.initCallbacks = function() {
|
||||||
|
|
||||||
this.socket.on("voteskip", function(data) {
|
this.socket.on("voteskip", function(data) {
|
||||||
if(this.channel != null) {
|
if(this.channel != null) {
|
||||||
this.channel.voteskip(this);
|
this.channel.tryVoteskip(this);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue