mirror of
https://github.com/parnic/node-intellicenter.git
synced 2025-06-16 18:20:14 -05:00
Add ability to specify multicast interface
When you have multiple network adapters/interfaces, the system can choose the wrong one. This allows you to be explicit about which one you broadcast on.
This commit is contained in:
8
dist/finder.d.ts
vendored
8
dist/finder.d.ts
vendored
@ -20,7 +20,13 @@ export declare class UnitInfo {
|
||||
* * `"serverFound"` - fired immediately when an IntelliCenter unit has been located; receives a {@linkcode UnitInfo} argument
|
||||
*/
|
||||
export declare class FindUnits extends EventEmitter {
|
||||
constructor();
|
||||
broadcastInterface?: string | undefined;
|
||||
/**
|
||||
* Creates a new finder.
|
||||
*
|
||||
* @param broadcastInterface the address of the interface to send the broadcast to. If not specified, will use system selection. Only necessary if you have more than one network adapter/interface and want to search on a specific one.
|
||||
*/
|
||||
constructor(broadcastInterface?: string | undefined);
|
||||
private finder;
|
||||
private bound;
|
||||
private message;
|
||||
|
12
dist/finder.js
vendored
12
dist/finder.js
vendored
@ -31,8 +31,15 @@ export class UnitInfo {
|
||||
* * `"serverFound"` - fired immediately when an IntelliCenter unit has been located; receives a {@linkcode UnitInfo} argument
|
||||
*/
|
||||
export class FindUnits extends EventEmitter {
|
||||
constructor() {
|
||||
broadcastInterface;
|
||||
/**
|
||||
* Creates a new finder.
|
||||
*
|
||||
* @param broadcastInterface the address of the interface to send the broadcast to. If not specified, will use system selection. Only necessary if you have more than one network adapter/interface and want to search on a specific one.
|
||||
*/
|
||||
constructor(broadcastInterface) {
|
||||
super();
|
||||
this.broadcastInterface = broadcastInterface;
|
||||
// construct mDNS packet to ping for intellicenter controllers
|
||||
this.message = Buffer.alloc(34);
|
||||
let offset = 0;
|
||||
@ -54,6 +61,9 @@ export class FindUnits extends EventEmitter {
|
||||
this.finder = createSocket("udp4");
|
||||
this.finder
|
||||
.on("listening", () => {
|
||||
if (this.broadcastInterface) {
|
||||
this.finder.setMulticastInterface(this.broadcastInterface);
|
||||
}
|
||||
this.finder.setBroadcast(true);
|
||||
this.finder.setMulticastTTL(128);
|
||||
if (!this.bound) {
|
||||
|
2
dist/finder.js.map
vendored
2
dist/finder.js.map
vendored
File diff suppressed because one or more lines are too long
10
finder.ts
10
finder.ts
@ -51,7 +51,12 @@ export class UnitInfo {
|
||||
* * `"serverFound"` - fired immediately when an IntelliCenter unit has been located; receives a {@linkcode UnitInfo} argument
|
||||
*/
|
||||
export class FindUnits extends EventEmitter {
|
||||
constructor() {
|
||||
/**
|
||||
* Creates a new finder.
|
||||
*
|
||||
* @param broadcastInterface the address of the interface to send the broadcast to. If not specified, will use system selection. Only necessary if you have more than one network adapter/interface and want to search on a specific one.
|
||||
*/
|
||||
constructor(public broadcastInterface?: string) {
|
||||
super();
|
||||
|
||||
// construct mDNS packet to ping for intellicenter controllers
|
||||
@ -76,6 +81,9 @@ export class FindUnits extends EventEmitter {
|
||||
this.finder = createSocket("udp4");
|
||||
this.finder
|
||||
.on("listening", () => {
|
||||
if (this.broadcastInterface) {
|
||||
this.finder.setMulticastInterface(this.broadcastInterface);
|
||||
}
|
||||
this.finder.setBroadcast(true);
|
||||
this.finder.setMulticastTTL(128);
|
||||
|
||||
|
Reference in New Issue
Block a user