beginning node integration
This commit is contained in:
parent
10626ad3df
commit
7ea4275e31
2553 changed files with 391925 additions and 0 deletions
50
index.js
Normal file
50
index.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// dependencies
|
||||
var app = require('express')()
|
||||
, http = require('http')
|
||||
, server = http.createServer(app)
|
||||
, io = require('socket.io').listen(server)
|
||||
, osc = require("osc");
|
||||
|
||||
// static files serving
|
||||
app.get('/', function (req, res) {
|
||||
res.sendfile(__dirname + '/lib-dev/index.html');
|
||||
});
|
||||
|
||||
// localhost:1337
|
||||
server.listen(1337)
|
||||
|
||||
// osc event listener
|
||||
var udpPort = new osc.UDPPort({
|
||||
localAddress: "0.0.0.0",
|
||||
localPort: 6666
|
||||
});
|
||||
|
||||
|
||||
|
||||
udpPort.open();
|
||||
|
||||
|
||||
|
||||
// IO socket between node server and web app
|
||||
io.sockets.on('connection', function (socket) {
|
||||
socket.on('sendOsc', function (data) {
|
||||
udpPort.send({
|
||||
address: data.path,
|
||||
args: data.args
|
||||
}, data.host, data.port);
|
||||
|
||||
|
||||
});
|
||||
|
||||
udpPort.on("message", function (data) {
|
||||
socket.emit('receiveOsc',data);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue