diff --git a/lib/rtsp.js b/lib/rtsp.js index dd40818..4d4c848 100644 --- a/lib/rtsp.js +++ b/lib/rtsp.js @@ -30,7 +30,6 @@ function RtspServer(options, external) { } RtspServer.prototype.connectHandler = function(socket) { - if (this.handling && !this.clientConnected) { socket.end(); return; @@ -97,4 +96,8 @@ RtspServer.prototype.disconnectHandler = function() { }; +RtspServer.prototype.stop = function() { + this.rtp.stop() +} + module.exports = RtspServer; diff --git a/lib/server.js b/lib/server.js index b4b84f7..0cb06c9 100644 --- a/lib/server.js +++ b/lib/server.js @@ -46,7 +46,6 @@ function NodeTunes(options) { this.netServer = null; this.rtspServer = new RtspServer(this.options, this); - } util.inherits(NodeTunes, EventEmitter); @@ -69,11 +68,11 @@ NodeTunes.prototype.start = function(callback) { } this.netServer = net.createServer(this.rtspServer.connectHandler.bind(this.rtspServer)).listen(port, function() { - - var ad = mdns.createAdvertisement(mdns.tcp('raop'), port, { + this.advertisement = mdns.createAdvertisement(mdns.tcp('raop'), port, { name: this.options.macAddress + '@' + this.options.serverName, txtRecord: this.txtSetup, }); + this.advertisement.start() if (callback) { callback(null, { @@ -93,6 +92,8 @@ NodeTunes.prototype.start = function(callback) { NodeTunes.prototype.stop = function() { debug('stopping nodetunes server'); this.netServer.close(); + this.rtspServer.stop(); + this.advertisement.stop(); }; module.exports = NodeTunes;