diff --git a/mopidy/http/__init__.py b/mopidy/http/__init__.py index 25e2dd46..c51eaf29 100644 --- a/mopidy/http/__init__.py +++ b/mopidy/http/__init__.py @@ -22,6 +22,7 @@ class Extension(ext.Extension): schema['port'] = config.Port() schema['static_dir'] = config.Path(optional=True) schema['zeroconf'] = config.String(optional=True) + schema['zeroconf-websocket'] = config.String(optional=True) return schema def validate_environment(self): diff --git a/mopidy/http/actor.py b/mopidy/http/actor.py index c5787fec..6510e6cf 100644 --- a/mopidy/http/actor.py +++ b/mopidy/http/actor.py @@ -25,8 +25,10 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener): self.hostname = config['http']['hostname'] self.port = config['http']['port'] - self.zeroconf_name = config['http']['zeroconf'] - self.zeroconf_service = None + self.zeroconf_http_name = config['http']['zeroconf'] + self.zeroconf_http_service = None + self.zeroconf_websocket_name = config['http']['zeroconf-websocket'] + self.zeroconf_websocket_service = None self._setup_server() self._setup_websocket_plugin() @@ -94,21 +96,36 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener): cherrypy.engine.start() logger.info('HTTP server running at %s', cherrypy.server.base()) - if self.zeroconf_name: - self.zeroconf_service = zeroconf.Zeroconf( - stype='_http._tcp', name=self.zeroconf_name, + if self.zeroconf_http_name: + self.zeroconf_http_service = zeroconf.Zeroconf( + stype='_http._tcp', name=self.zeroconf_http_name, host=self.hostname, port=self.port) - if self.zeroconf_service.publish(): + if self.zeroconf_http_service.publish(): logger.debug( 'Registered HTTP with Zeroconf as "%s"', - self.zeroconf_service.name) + self.zeroconf_http_service.name) else: logger.debug('Registering HTTP with Zeroconf failed.') + if self.zeroconf_websocket_name: + self.zeroconf_websocket_service = zeroconf.Zeroconf( + stype='_mopidy-http._tcp', name=self.zeroconf_websocket_name, + host=self.hostname, port=self.port) + + if self.zeroconf_websocket_service.publish(): + logger.debug( + 'Registered mopidy-http with Zeroconf as "%s"', + self.zeroconf_websocket_service.name) + else: + logger.debug('Registering mopidy-http with Zeroconf failed.') + def on_stop(self): - if self.zeroconf_service: - self.zeroconf_service.unpublish() + if self.zeroconf_http_service: + self.zeroconf_http_service.unpublish() + + if self.zeroconf_websocket_service: + self.zeroconf_websocket_service.unpublish() logger.debug('Stopping HTTP server') cherrypy.engine.exit()