mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-07 23:03:38 +00:00
add search type Multicast
This commit is contained in:
+67
-176
@@ -43,7 +43,7 @@ searchAll = function () {
|
||||
searching = true;
|
||||
ipcRenderer.send('disableSearchAll', '');
|
||||
document.getElementById('search-button').style.opacity = 0.2;
|
||||
// console.clear();
|
||||
//== console.clear();
|
||||
|
||||
for (let i in DEVICE.all) {
|
||||
DEVICE.infoUpdate(DEVICE.all[i], 'status', 'refresh');
|
||||
@@ -77,6 +77,9 @@ searchAll = function () {
|
||||
case 'UDPsocket':
|
||||
newSearchUDP(p, plugin);
|
||||
break;
|
||||
case 'multicast':
|
||||
newSearchMulticast(p, plugin);
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Unable to search for plugin ${p}`);
|
||||
@@ -102,18 +105,10 @@ searchAll = function () {
|
||||
};
|
||||
module.exports.searchAll = searchAll;
|
||||
|
||||
// ____ _
|
||||
// | _ \ (_)
|
||||
// | |_) | ___ _ __ _ ___ _ _ _ __
|
||||
// | _ < / _ \| '_ \| |/ _ \| | | | '__|
|
||||
// | |_) | (_) | | | | | (_) | |_| | |
|
||||
// |____/ \___/|_| |_| |\___/ \__,_|_|
|
||||
// _/ |
|
||||
// |__/
|
||||
|
||||
|
||||
newSearchBonjour = function (pluginType, plugin) {
|
||||
bonjour.find({ type: plugin.searchOptions.bonjourName }, (e) => {
|
||||
console.log(pluginType);
|
||||
|
||||
const validAddresses = [];
|
||||
for (let i in e.addresses) {
|
||||
@@ -131,29 +126,6 @@ newSearchBonjour = function (pluginType, plugin) {
|
||||
});
|
||||
};
|
||||
|
||||
// searchBonjour = function(){
|
||||
// bonjour.find({type: "qlab"}, function(e){
|
||||
// for(var i in e.addresses){
|
||||
// if(e.addresses[i].indexOf(":")){
|
||||
// e.addresses.splice(i, 1);
|
||||
// }
|
||||
// }
|
||||
// DEVICE.registerDevice({
|
||||
// type: "qlab",
|
||||
// name: e.name,
|
||||
// port: e.port,
|
||||
// addresses: e.addresses
|
||||
// })
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
// _______ _____ _____
|
||||
// |__ __/ ____| __ \
|
||||
// | | | | | |__) |
|
||||
// | | | | | ___/
|
||||
// | | | |____| |
|
||||
// |_| \_____|_|
|
||||
|
||||
newSearchTCP = function (pluginType, plugin) {
|
||||
for (let i = 0; i < allServers.length; i++) {
|
||||
@@ -220,107 +192,51 @@ findOnlineDevices = function () {
|
||||
}
|
||||
};
|
||||
|
||||
// window.searchTCP = function(){
|
||||
// var allInterfaces = require('os').networkInterfaces();
|
||||
// var validInterfaces = [];
|
||||
// for(var i in allInterfaces){
|
||||
// for(var j=0; j<allInterfaces[i].length; j++){
|
||||
// var iface = allInterfaces[i][j];
|
||||
|
||||
// if(iface.family=="IPv4" && iface.internal==false && iface.address.split(".")[0]!="169"){
|
||||
// validInterfaces.push(iface);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(var i=0; i<validInterfaces.length; i++){
|
||||
// var block = new netmask(validInterfaces[i].cidr);
|
||||
// var f = block.first.split(".");
|
||||
// var l = block.last.split(".");
|
||||
// var cur = [f[0], f[1], f[2], f[3]];
|
||||
|
||||
// for(var j=Number(f[2]); j<=Number(l[2]); j++){
|
||||
// cur[2] = j;
|
||||
// for(var k = Number(f[3]); k<Number(l[3]); k++){
|
||||
// cur[3] = k;
|
||||
// var ip = cur[0]+"."+cur[1]+"."+cur[2]+"."+cur[3];
|
||||
|
||||
// TCPtest(ip, 3033);
|
||||
// TCPtest(ip, 3039);
|
||||
// TCPtest(ip, 3040);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// TCPtest = function(address, port){
|
||||
// var client = net.createConnection(port, address, function(){
|
||||
// if(port==3033){
|
||||
// DEVICE.registerDevice({
|
||||
// type: "eos",
|
||||
// name: "ETC Eos Console",
|
||||
// port: 3032,
|
||||
// addresses: [address]
|
||||
// });
|
||||
// }else if(port==3040){
|
||||
// DEVICE.registerDevice({
|
||||
// type: "watchout",
|
||||
// name: "Watchout",
|
||||
// port: 3040,
|
||||
// addresses: [address]
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// client.on("error", function(err){
|
||||
// //no EOS here
|
||||
// });
|
||||
// }
|
||||
|
||||
// _ _ _____ _____
|
||||
// | | | | __ \| __ \
|
||||
// | | | | | | | |__) |
|
||||
// | | | | | | | ___/
|
||||
// | |__| | |__| | |
|
||||
// \____/|_____/|_|
|
||||
|
||||
const pjLinkMessage = Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]);
|
||||
const xAirMessage = Buffer.from([0x2f, 0x78, 0x69, 0x6e, 0x66, 0x6f]);
|
||||
const serverUDP = dgram.createSocket('udp4');
|
||||
const serverUDP2 = dgram.createSocket('udp4');
|
||||
//const pjLinkMessage = Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]);
|
||||
//const xAirMessage = Buffer.from([0x2f, 0x78, 0x69, 0x6e, 0x66, 0x6f]);
|
||||
//const serverUDP = dgram.createSocket('udp4');
|
||||
//const serverUDP2 = dgram.createSocket('udp4');
|
||||
|
||||
newSearchUDP = function (pluginType, plugin) {
|
||||
const i = searchSockets.push(dgram.createSocket('udp4')) - 1;
|
||||
|
||||
searchSockets[i].bind(plugin.searchOptions.listenPort, () => {
|
||||
searchSockets[i].send(
|
||||
plugin.searchOptions.searchBuffer,
|
||||
plugin.searchOptions.devicePort,
|
||||
'255.255.255.255',
|
||||
(err) => {
|
||||
// console.log(err)
|
||||
}
|
||||
);
|
||||
setTimeout(() => {
|
||||
searchSockets[i].send(
|
||||
plugin.searchOptions.searchBuffer,
|
||||
plugin.searchOptions.devicePort,
|
||||
'255.255.255.255',
|
||||
(err) => {
|
||||
// console.log(err)
|
||||
}
|
||||
);
|
||||
}, 100);
|
||||
setTimeout(() => {
|
||||
searchSockets[i].send(
|
||||
plugin.searchOptions.searchBuffer,
|
||||
plugin.searchOptions.devicePort,
|
||||
'255.255.255.255',
|
||||
(err) => {
|
||||
// console.log(err)
|
||||
}
|
||||
);
|
||||
}, 400);
|
||||
|
||||
// searchSockets[i].send(
|
||||
// plugin.searchOptions.searchBuffer,
|
||||
// plugin.searchOptions.devicePort,
|
||||
// '255.255.255.255',
|
||||
// (err) => {
|
||||
// // console.log(err)
|
||||
// }
|
||||
// );
|
||||
// setTimeout(() => {
|
||||
// searchSockets[i].send(
|
||||
// plugin.searchOptions.searchBuffer,
|
||||
// plugin.searchOptions.devicePort,
|
||||
// '255.255.255.255',
|
||||
// (err) => {
|
||||
// // console.log(err)
|
||||
// }
|
||||
// );
|
||||
// }, 100);
|
||||
// setTimeout(() => {
|
||||
// console.log('send')
|
||||
// searchSockets[i].send(
|
||||
// plugin.searchOptions.searchBuffer,
|
||||
// plugin.searchOptions.devicePort,
|
||||
// '255.255.255.255',
|
||||
// (err) => {
|
||||
// // console.log(err)
|
||||
// }
|
||||
// );
|
||||
// }, 400);
|
||||
|
||||
searchSockets[i].on('message', (msg, info) => {
|
||||
if (plugin.searchOptions.validateResponse(msg, info)) {
|
||||
if (plugin.searchOptions.validateResponse(msg, info, DEVICE.all)) {
|
||||
searchSockets[i].close();
|
||||
DEVICE.registerDevice({
|
||||
type: pluginType,
|
||||
defaultName: plugin.defaultName,
|
||||
@@ -332,57 +248,32 @@ newSearchUDP = function (pluginType, plugin) {
|
||||
});
|
||||
searchSockets[i].on('listening', () => {
|
||||
searchSockets[i].setBroadcast(true);
|
||||
searchSockets[i].send(
|
||||
plugin.searchOptions.searchBuffer,
|
||||
plugin.searchOptions.devicePort,
|
||||
'255.255.255.255',
|
||||
(err) => {
|
||||
// console.log(err)
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
// searchUDP = function(){
|
||||
|
||||
// dgramPJLink = dgram.createSocket('udp4');
|
||||
// dgramPJLink.bind(function(){
|
||||
// dgramPJLink.send(pjLinkMessage, 4352, '255.255.255.255', (err) => {
|
||||
// //console.log(err)
|
||||
// });
|
||||
// dgramPJLink.on('message',function(msg,info){
|
||||
// if(msg.toString().indexOf("%2ACKN")==0){
|
||||
// DEVICE.registerDevice({
|
||||
// type: "pjlink",
|
||||
// name: "PJLink Projector",
|
||||
// port: 4352,
|
||||
// addresses: [info.address]
|
||||
// })
|
||||
// }
|
||||
// });
|
||||
|
||||
// });
|
||||
// dgramPJLink.on('listening', function(){
|
||||
// dgramPJLink.setBroadcast(true);
|
||||
// });
|
||||
|
||||
// dgramXAir = dgram.createSocket('udp4');
|
||||
// dgramXAir.bind(function(){
|
||||
// dgramXAir.send(xAirMessage, 10024, '255.255.255.255', (err) => {
|
||||
// //console.log(err)
|
||||
// });
|
||||
// setTimeout(function(){
|
||||
// dgramXAir.send(xAirMessage, 10024, '255.255.255.255', (err) => {
|
||||
// //console.log(err)
|
||||
// });
|
||||
// }, 100);
|
||||
|
||||
// dgramXAir.on('message',function(msg,info){
|
||||
// if(msg.toString().indexOf("/xinfo,ssss")){
|
||||
// DEVICE.registerDevice({
|
||||
// type: "xair",
|
||||
// name: "X Air Mixer",
|
||||
// port: 10024,
|
||||
// addresses: [info.address]
|
||||
// })
|
||||
// }
|
||||
// });
|
||||
|
||||
// });
|
||||
// dgramXAir.on('listening', function(){
|
||||
// dgramXAir.setBroadcast(true);
|
||||
// });
|
||||
|
||||
// }
|
||||
newSearchMulticast = function (pluginType, plugin) {
|
||||
let socket = dgram.createSocket('udp4');
|
||||
socket.on('message', (msg, info) => {
|
||||
if (plugin.searchOptions.validateResponse(msg, info)) {
|
||||
socket.close();
|
||||
DEVICE.registerDevice({
|
||||
type: pluginType,
|
||||
defaultName: plugin.defaultName,
|
||||
port: plugin.defaultPort,
|
||||
addresses: [info.address],
|
||||
});
|
||||
}
|
||||
});
|
||||
socket.bind(plugin.searchOptions.port, function(){
|
||||
socket.addMembership(plugin.searchOptions.address);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user