From e74d892e3dc33a058d88de58c4136a57a31403cf Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 10 Dec 2017 15:10:34 +0100 Subject: [PATCH] zeroconf: 1st implementation try (http.tcp ok, osc.udp not sure) (issue #118) --- app/main/osc.js | 7 +++++++ app/main/server.js | 7 +++++++ app/main/zeroconf.js | 3 +++ app/package.json | 13 +++++++------ 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 app/main/zeroconf.js diff --git a/app/main/osc.js b/app/main/osc.js index d69badcb..affe6fbb 100644 --- a/app/main/osc.js +++ b/app/main/osc.js @@ -5,6 +5,7 @@ require('vmodule')('serialport', {}, {global: true}) var osc = require('osc'), ipc = require('./server').ipc, settings = require('./settings'), + zeroconf = require('./zeroconf'), oscInPort = settings.read('oscInPort') || settings.read('httpPort'), debug = settings.read('debug'), vm = require('vm'), @@ -17,6 +18,12 @@ var oscServer = new osc.UDPPort({ metadata: true }) +zeroconf.publish({ + name: settings.read('appName'), + protocol: 'upd', + type: 'osc', + port: oscInPort +}) var parseType = function(type){ var t = type[0].match(/[bhtdscrmifTFNI]/) diff --git a/app/main/server.js b/app/main/server.js index 5bb038f2..f2ecc90d 100644 --- a/app/main/server.js +++ b/app/main/server.js @@ -6,6 +6,7 @@ var express = require('express')(), io = require('socket.io')(server), ipc = {}, settings = require('./settings'), + zeroconf = require('./zeroconf'), appAddresses = settings.read('appAddresses'), clients = {} @@ -27,6 +28,12 @@ express.get('*', function(req, res){ server.listen(settings.read('httpPort')) +zeroconf.publish({ + name: settings.read('appName'), + type: 'http', + port: settings.read('httpPort') +}) + ipc.send = function(name,data,clientId) { if (clientId) { io.to(clientId).emit(name,data) diff --git a/app/main/zeroconf.js b/app/main/zeroconf.js new file mode 100644 index 00000000..74aa0a99 --- /dev/null +++ b/app/main/zeroconf.js @@ -0,0 +1,3 @@ +var zeroconf = require('bonjour')() + +module.exports = zeroconf diff --git a/app/package.json b/app/package.json index 7ad7af76..bd2706b0 100644 --- a/app/package.json +++ b/app/package.json @@ -21,15 +21,16 @@ "license": "GPL-3.0", "main": "index.js", "dependencies": { - "vmodule":"1.0.1", + "bonjour": "^3.5.0", + "chokidar": "1.7.0", "electron-localshortcut": "2.0.2", - "osc": "2.2.0", - "yargs": "10.0.3", - "socket.io": "2.0.4", "express": "4.16.2", "jquery": "3.2.1", - "chokidar": "1.7.0", - "python-shell":"0.4.0" + "osc": "2.2.0", + "python-shell": "0.4.0", + "socket.io": "2.0.4", + "vmodule": "1.0.1", + "yargs": "10.0.3" }, "scripts": { "start": "electron ."