zeroconf: 1st implementation try (http.tcp ok, osc.udp not sure) (issue #118)

This commit is contained in:
jean-emmanuel 2017-12-10 15:10:34 +01:00
parent 95ae2f50e8
commit d69d20b6e4
4 changed files with 24 additions and 6 deletions

View file

@ -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]/)

View file

@ -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)

3
app/main/zeroconf.js Normal file
View file

@ -0,0 +1,3 @@
var zeroconf = require('bonjour')()
module.exports = zeroconf

View file

@ -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 ."