Skip to content

Commit

Permalink
fix(stop): use start/stop interface on mDNS to correctly stop servers (
Browse files Browse the repository at this point in the history
  • Loading branch information
npwalker authored Aug 3, 2016
1 parent 73767dd commit be07681
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/rtsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function RtspServer(options, external) {
}

RtspServer.prototype.connectHandler = function(socket) {

if (this.handling && !this.clientConnected) {
socket.end();
return;
Expand Down Expand Up @@ -97,4 +96,8 @@ RtspServer.prototype.disconnectHandler = function() {

};

RtspServer.prototype.stop = function() {
this.rtp.stop()
}

module.exports = RtspServer;
7 changes: 4 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function NodeTunes(options) {

this.netServer = null;
this.rtspServer = new RtspServer(this.options, this);

}

util.inherits(NodeTunes, EventEmitter);
Expand All @@ -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, {
Expand All @@ -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;

0 comments on commit be07681

Please sign in to comment.