How to use the node-osc.Server function in node-osc

To help you get started, we’ve selected a few node-osc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moxuse / Kusabi / index.js View on Github external
// });
  // psci.stderr.setEncoding("utf-8");
  // psci.stderr.on("data", data => {
  //   console.log(data);
  //   socket.emit("response", data);
  // });
  /**
   * interaction with editor of render process
   */

  console.log("sthart watching Main.purs");

  /**]
   * osc listen
   */
  const oscServer = new OscServer(config.osc.port, config.osc.host);
  oscServer.on("message", function(msg) {
    // console.log("on osc msg:", msg);
    socket.emit(msg[0], msg[1]);
  });
});
github kn0ll / osc.io / lib / osc.io.js View on Github external
function server_channel_handler(socket) {
  var ns = socket.namespace.name,
    port = parse_io_ns_option(ns),
    osc_server = new osc.Server(port, '0.0.0.0');

  // proxy osc messages from udp to socket.io
  osc_server.on('message', function(msg) {
    socket.emit('message', msg);
  });
}
github triss / duplex-nexus-osc / nxserver.js View on Github external
// set up serving of static pages from this folder
    app = connect().use(connect.static(__dirname)).listen(8080),

    // set up web service port
    io = require('socket.io').listen(app);
    
    console.log('http server on 8080');

// osc client
var osc = require('node-osc'),
    oscClient = new osc.Client('localhost', 57120);
    console.log('osc client on 57120');

// osc server
var oscServer = new osc.Server(4444, '0.0.0.0');
    console.log('osc server on 4444');
    

////////////////////////////////////////////////////////////////////////////////
// widget management and messaging to web clients is handled here
////////////////////////////////////////////////////////////////////////////////

// a collection to store info about our widgets - this cache is used to update 
// new clients upon connection
var widgets = {};

// creates a widget
function createWidget(name, type, x, y, w, h) {
    // update our cache of widget information
    widgets[name] = {
        'name': name,
github stimulant / ampm / model / network.js View on Github external
key: 'sessionId',
                secret: secret,
                store: store,
                success: function(data, accept) {
                    logger.info('Socket access authorized for user', data.user);
                    accept(null, true);
                },
                fail: function(data, message, error, accept) {
                    logger.info('Socket access unauthorized.', message, error);
                    accept(null, false);
                }
            }));
        }

        //// Set up OSC connection from app.
        this.transports.oscFromApp = new osc.Server(this.get('oscFromAppPort'));

        // handle straight messages
        this.transports.oscFromApp.on('message', _.bind(function(message, info) {
            // handle bundles
            if (message[0] == '#bundle')
                this._handleOsc(this.transports.oscFromApp, message[2], info);
            else
                this._handleOsc(this.transports.oscFromApp, message, info);
        }, this));

        //// Set up OSC connection to app.
        this.transports.oscToApp = new osc.Client('127.0.0.1', this.get('oscToAppPort'));

        //// Set up socket connection to app.
        this.transports.socketToApp = ioServer.listen(this.get('socketToAppPort'));
    },
github automata / osc-web / bridge.js View on Github external
socket.on('config', function (obj) {
    console.log('config', obj);
    oscServer = new osc.Server(obj.server.port, obj.server.host);
    oscClient = new osc.Client(obj.client.host, obj.client.port);

    oscClient.send('/status', socket.id + ' connected');

    oscServer.on('message', function(msg, rinfo) {
      socket.emit('message', msg);
      console.log('sent OSC message to WS', msg, rinfo);
    });
  });
  socket.on('message', function (obj) {
github genekogan / p5js-osc / bridge.js View on Github external
socket.on("config", function (obj) {
		isConnected = true;
    	oscServer = new osc.Server(obj.server.port, obj.server.host);
	    oscClient = new osc.Client(obj.client.host, obj.client.port);
	    oscClient.send('/status', socket.sessionId + ' connected');
		oscServer.on('message', function(msg, rinfo) {
			socket.emit("message", msg);
		});
		socket.emit("connected", 1);
	});
 	socket.on("message", function (obj) {
github kinetecharts / openPerform / server / sockets / OSCServer.js View on Github external
constructor() {
    this.oscServer = new osc.Server(config.ports.incoming, '0.0.0.0');
  
    this.wss = new WebSocket.Server({ port: config.ports.outgoing });
    this.wss.on('connection', this.onBroadcastConnection.bind(this));
    this.wss.on('error', this.onBroadcastError.bind(this));
    this.wss.on('listening', this.onBroadcastListening.bind(this));
  }
github hundredrabbits / Ronin / desktop / sources / scripts / osc.js View on Github external
this.start = function () {
    const server = new osc.Server(49162, '0.0.0.0')
    server.on('message', this.onMsg)
  }
github pwstegman / bci.js / lib / network / oscCollect.js View on Github external
return new Promise(function (resolve, reject) {
		var data = [];

		if (samples == 0) {
			resolve(data);
			return;
		}

		var server = new osc.Server(port, address);

		server.on("message", function (msg, rinfo) {
			if (msg[0] == header) {
				data.push(msg.slice(1));

				if (data.length > samples) {
					server.kill();
					reject("More OSC samples seen than expected");
				}else if (data.length == samples) {
					server.kill();
					resolve(data);
					data = [];
				}
			}
		});
	});
github diegodorado / atom-live-emojing / lib / sc.js View on Github external
constructor(data) {
    this.server = new osc.Server(3333, '0.0.0.0')
    this.server.on("message", function (msg, rinfo) {
      data.callback(msg)
    })
  }

node-osc

pyOSC inspired library for sending and receiving OSC messages

LGPL-3.0
Latest version published 10 days ago

Package Health Score

76 / 100
Full package analysis