fuck timers

This commit is contained in:
reality 2014-02-17 20:31:20 +00:00
parent 0913f382d7
commit e4997cd915

View File

@ -9,9 +9,11 @@ var _ = require('underscore')._,
var radio = function(dbot) { var radio = function(dbot) {
this.listening = false; this.listening = false;
this.data = false; this.data = false;
this.stream = false;
this.internalAPI = { this.internalAPI = {
'startRadio': function() { 'startRadio': function() {
var stream = icecast.createReadStream(this.config.stream); var stream = icecast.createReadStream(this.config.stream);
this.stream = stream;
stream.on('connect', function() { stream.on('connect', function() {
this.listening = true; this.listening = true;
@ -40,6 +42,7 @@ var radio = function(dbot) {
}.bind(this)); }.bind(this));
stream.on('end', function() { stream.on('end', function() {
this.stream.close();
this.listening = false; this.listening = false;
}.bind(this)); }.bind(this));
}.bind(this), }.bind(this),
@ -55,6 +58,9 @@ var radio = function(dbot) {
this.onLoad = function() { this.onLoad = function() {
this.internalAPI.getRadio(); this.internalAPI.getRadio();
}.bind(this); }.bind(this);
this.onDestroy = function() {
this.stream.close();
}.bind(this);
}; };
exports.fetch = function(dbot) { exports.fetch = function(dbot) {