hobbyquaker / artnet

Send ArtDMX to an Art-Net node (DMX512, Stage Lighting) 💡🎬
MIT License
123 stars 23 forks source link

Missing case: pass host, iface and port via constructor options #22

Open brunoimbrizi opened 6 years ago

brunoimbrizi commented 6 years ago

I am using this library to connect to Elation E-Node 8 II. I was not working with the usage suggested in the readme. After some investigation I noticed the socket had to be bound to a specific port - instead of the default random port assigned by dgram.

If I set host to 2.39.2.202 for example:

// doesn't work
var artnet = require('artnet')({ host: '2.39.2.202' });

The conditional statement between lines 26 and 35 are skipped and the socket is bound to a random port.

If I set iface to my local made up IP address 2.39.2.100:

// works
var artnet = require('artnet')({ iface: '2.39.2.100' });

Then the socket port is set and I can communicate with the E-Node 8 II properly.

but...

If I want to set both host and iface - because I have to communicate with more than one Artnet for example` then it stops working:

// doesn't work
var artnetA = require('artnet')({ iface: '2.39.2.100', host: '2.39.2.202' });
var artnetB = require('artnet')({ iface: '2.39.2.100', host: '2.39.2.203' });
brunoimbrizi commented 6 years ago

Workaround; create an instance passing only iface and then call setHost() after.

const Artnet = require('artnet');

var artnetA = new Artnet({ iface: '2.39.2.202' });
artnetA.setHost('2.39.2.100');