Custom Module help

Hi,

I apologize if this is somewhere and I’ve missed it - I swear I’ve searched and searched, but am pulling my hair out…

I’m just trying to setup a simple custom-module based on the docs/examples, and make sure I have things working, but have been unable to do so. Here is my module:

module.exports = {

    init: function() {
        console.log('init successful')
    },

    oscOutFilter: function(data) {
        console.log('oscOutFilter')
        console.log(data)
        return data
    },

    oscInFilter: function(data) {
        console.log('oscInFilter')
        console.log(data)
        return data
    }

}

I have a single button widget:

"widgets": [
  {
    "type": "button",
    "top": 30,
    "left": 10,
    "id": "button_1",
    "visible": true,
    "interaction": true,
    //...
    "on": 1,
    "off": 0,
    "mode": "push",
    "doubleTap": false,
    "value": "myVal",
    "default": "",
    "linkId": "",
    "script": "",
    "address": "/myTest",
    "preArgs": [],
    "typeTags": "",
    "decimals": 2,
    "target": "",
    "ignoreDefaults": false,
    "bypass": false
  }
],

When I start the client, the “init successful” message appears in the console, but I cannot for the life of me get any of the other debug messages to show when I click the button.

Any suggestions?

So perhaps this has to do with my inexperience with OSC in general…I needed to add a target attribute in order for the oscInFilter and oscOutFilter functions to be triggered.

My goal is to be able to just trigger different functions based upon the address - is the “target” then arbitrary since it’ll trigger oscOutFilter no matter what?

Yes, you need at least one target so that the widget sends a message to catch it with the custom module. An invalid one will do (as long as it contains a colon separator) but will produce an error if the message is not bypassed (or its target modified).

Thanks - I ended up setting a default send and that’s exactly what I needed. Much appreciated!

Hi
To help others users, would you mind to post your solution session js file ?
Cheers

Sorry for the late response. The solution was to just set a default “send” param on the server itself: Server configuration - Open Stage Control (set to localhost:8080 to target itself). I changed my mind with the custom module and am handling my logic on the oscInFilter now, hence why I am targeting the the server itself.

It strongly recommend tp avoid doing this, every message sent will be received as well and it’s absolutely not necessary in order to process them in the custom module (having the message sent is enough to catch them in the oscOutFilter function).