How to use the osc.Server function in osc

To help you get started, we’ve selected a few 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 automata / osc-web / deprecated / osc-web-server.js View on Github external
client.on('message', function(obj) {
        // in this example, first browser-client sends a configuration object.
        // it contains 'port' and 'host' settings for Server and Client.
        if ('config' in obj) {
            var config = obj.config;
            OSCServer = new osc.Server(config.server.port, config.server.host);
            OSCClient = new osc.Client(config.client.host, config.client.port);
            
            var message = new osc.Message('/status', client.sessionId + ' connected');
            OSCServer.send(message, OSCClient);
            
            // OSCServer dispatches 'oscmessage' event when receives the message.
            // so we attach handler on the event for global message handling.
            OSCServer.on('oscmessage', function(msg) {
                // check message's address pattern.
                if (msg.checkAddrPattern('/lp/matrix')) {
                    // and check messages typetag.
                    if (msg.checkTypetag('iii')) {
                        client.send({
                            OSCMessage: {
                                address: msg.address,
                                typetags: msg.typetags,