Permalink
Browse files

First commit

  • Loading branch information...
oierbravo committed Jan 11, 2012
0 parents commit 3b3a94249c3558ac43755bae57760829ad4d79a7
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1,3 @@
+[submodule "node-osc"]
+ path = node-osc
+ url = git://github.com/automata/node-osc.git
No changes.
@@ -0,0 +1,5 @@
+nOSCaine
+========
+Nodejs OSC Sniffer
+
+Work in progress.
@@ -0,0 +1,62 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express')
+ , routes = require('./routes')
+
+var app = module.exports = express.createServer();
+
+// Configuration
+
+app.configure(function(){
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+});
+
+app.configure('production', function(){
+ app.use(express.errorHandler());
+});
+
+// Routes
+
+app.get('/', routes.index);
+
+var io = require('socket.io');
+io = io.listen(app);
+
+
+app.listen(3000);
+console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
+
+var osc = require('./node-osc/lib/osc');
+
+var oscServer = new osc.Server(9001, '0.0.0.0');
+// bind callbacks.
+io.sockets.on('connection', function(socket) {
+ socket.broadcast.emit('info', socket.sessionId + ' connected');
+ socket.on('sniff',function (serverInfo){
+ console.log(serverInfo);
+ });
+ oscServer.on("message", function (msg, rinfo) {
+ console.log("OSC message:");
+ console.log(msg);
+ socket.emit('oscMessage', { message: parseMessage(msg) });
+});
+ });
+function parseMessage(msg){
+
+ return {
+ address: msg.shift()
+ ,args: msg
+ }
+}
63 app.js
@@ -0,0 +1,63 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express')
+ , routes = require('./routes')
+
+var app = module.exports = express.createServer();
+
+// Configuration
+
+app.configure(function(){
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+});
+
+app.configure('production', function(){
+ app.use(express.errorHandler());
+});
+
+// Routes
+
+app.get('/', routes.index);
+
+var io = require('socket.io');
+io = io.listen(app);
+
+
+app.listen(3000);
+console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
+
+var osc = require('./node-osc/lib/osc');
+
+var oscServer = new osc.Server(9001, '0.0.0.0');
+// bind callbacks.
+io.sockets.on('connection', function(socket) {
+ socket.broadcast.emit('info', socket.sessionId + ' connected');
+
+ socket.on("sniff", function(server){
+ console.log(server);
+ });
+ oscServer.on("message", function (msg, rinfo) {
+ console.log("OSC message:");
+ console.log(msg);
+ socket.emit('oscMessage', { message: parseMessage(msg) });
+});
+ });
+function parseMessage(msg){
+
+ return {
+ address: msg.shift()
+ ,args: msg
+ }
+}
Submodule node-osc added at 204d48
@@ -0,0 +1,9 @@
+{
+ "name": "application-name"
+ , "version": "0.0.1"
+ , "private": true
+ , "dependencies": {
+ "express": "2.5.1"
+ , "jade": ">= 0.0.1"
+ }
+}
@@ -0,0 +1,19 @@
+$(document).ready(function(){
+var socket = io.connect('http://127.0.0.1',{port:3000});
+ socket.on('connect',function(){
+ console.log('con');
+ });
+ socket.on('oscMessage', function (data) {
+ //console.log(data);
+ console.log(data.message);
+ $('#messages').append($('<li></li>').text(data.message.address + ' ' + data.message.args.join(',')));
+ });
+ $('#sniff-btn').click(function(){
+ server = {
+ host: $('input[name="host"]').val()
+ ,port: $('input[name="port"]').val()
+ }
+ socket.emit('sniff', server);
+
+ });
+ });

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,52 @@
+<style type="text/css">
+ /* Override some defaults */
+ html, body {
+ background-color: #eee;
+ }
+ body {
+ padding-top: 40px; /* 40px to make the container go all the way to the bottom of the topbar */
+ }
+ .container > footer p {
+ text-align: center; /* center align it with the container */
+ }
+ .container {
+ width: 820px; /* downsize our container to make the content feel a bit tighter and more cohesive. NOTE: this removes two full columns from the grid, meaning you only go to 14 columns and not 16. */
+ }
+
+ /* The white background content wrapper */
+ .content {
+ background-color: #fff;
+ padding: 20px;
+ margin: 0 -20px; /* negative indent the amount of the padding to maintain the grid system */
+ -webkit-border-radius: 0 0 6px 6px;
+ -moz-border-radius: 0 0 6px 6px;
+ border-radius: 0 0 6px 6px;
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
+ box-shadow: 0 1px 2px rgba(0,0,0,.15);
+ }
+
+ /* Page header tweaks */
+ .page-header {
+ background-color: #f5f5f5;
+ padding: 20px 20px 10px;
+ margin: -20px -20px 20px;
+ }
+
+ /* Styles you shouldn't keep as they are for displaying this base example only */
+ .content .span10,
+ .content .span4 {
+ min-height: 500px;
+ }
+ /* Give a quick and non-cross-browser friendly divider */
+ .content .span4 {
+ margin-left: 0;
+ padding-left: 19px;
+ border-left: 1px solid #eee;
+ }
+
+ .topbar .btn {
+ border: 0;
+ }
+
+ </style>
Oops, something went wrong.

0 comments on commit 3b3a942

Please sign in to comment.