Add zeroconf server detection tool
This commit is contained in:
parent
1263668ca5
commit
9988018aad
@ -1,5 +1,5 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<widget id="com.netsyms.BusinessMobile" version="1.2.1.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
<widget id="com.netsyms.BusinessMobile" version="1.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||||
<name>Business</name>
|
<name>Business</name>
|
||||||
<description>
|
<description>
|
||||||
Mobile client for the Netsyms Business Apps.
|
Mobile client for the Netsyms Business Apps.
|
||||||
@ -50,5 +50,6 @@
|
|||||||
<plugin name="cordova-plugin-splashscreen" spec="git+https://github.com/apache/cordova-plugin-splashscreen.git" />
|
<plugin name="cordova-plugin-splashscreen" spec="git+https://github.com/apache/cordova-plugin-splashscreen.git" />
|
||||||
<plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
|
<plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
|
||||||
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
|
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
|
||||||
|
<plugin name="cordova-plugin-zeroconf" spec="^1.2.5" />
|
||||||
<plugin name="phonegap-plugin-barcodescanner" spec="^6.0.6" />
|
<plugin name="phonegap-plugin-barcodescanner" spec="^6.0.6" />
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -8,3 +8,4 @@ cordova-plugin-statusbar=https://github.com/apache/cordova-plugin-statusbar.git
|
|||||||
cordova-plugin-headercolor=https://github.com/tomloprod/cordova-plugin-headercolor.git
|
cordova-plugin-headercolor=https://github.com/tomloprod/cordova-plugin-headercolor.git
|
||||||
cordova-plugin-inappbrowser=https://github.com/apache/cordova-plugin-inappbrowser.git
|
cordova-plugin-inappbrowser=https://github.com/apache/cordova-plugin-inappbrowser.git
|
||||||
cordova-plugin-app-version=https://github.com/whiteoctober/cordova-plugin-app-version.git
|
cordova-plugin-app-version=https://github.com/whiteoctober/cordova-plugin-app-version.git
|
||||||
|
cordova-plugin-zeroconf=https://github.com/becvert/cordova-plugin-zeroconf.git
|
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "com.netsyms.BusinessMobile",
|
"name": "com.netsyms.BusinessMobile",
|
||||||
"displayName": "Business for Mobile",
|
"displayName": "Business for Mobile",
|
||||||
"version": "1.2.1",
|
"version": "1.3",
|
||||||
"description": "Mobile client for the Netsyms Business Apps.",
|
"description": "Mobile client for the Netsyms Business Apps.",
|
||||||
"main": "index.html",
|
"main": "index.html",
|
||||||
"author": "Netsyms Technologies",
|
"author": "Netsyms Technologies",
|
||||||
"license": "netsyms-business-license",
|
"license": "netsyms-business-license",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cordova-android": "^6.2.3",
|
"cordova-android": "^6.2.3",
|
||||||
|
"cordova-plugin-add-swift-support": "^1.7.0",
|
||||||
"cordova-plugin-app-version": "^0.1.9",
|
"cordova-plugin-app-version": "^0.1.9",
|
||||||
"cordova-plugin-compat": "^1.1.0",
|
"cordova-plugin-compat": "^1.1.0",
|
||||||
"cordova-plugin-console": "git+https://github.com/apache/cordova-plugin-console.git",
|
"cordova-plugin-console": "git+https://github.com/apache/cordova-plugin-console.git",
|
||||||
@ -19,6 +20,7 @@
|
|||||||
"cordova-plugin-splashscreen": "git+https://github.com/apache/cordova-plugin-splashscreen.git",
|
"cordova-plugin-splashscreen": "git+https://github.com/apache/cordova-plugin-splashscreen.git",
|
||||||
"cordova-plugin-statusbar": "^2.2.3",
|
"cordova-plugin-statusbar": "^2.2.3",
|
||||||
"cordova-plugin-whitelist": "^1.3.2",
|
"cordova-plugin-whitelist": "^1.3.2",
|
||||||
|
"cordova-plugin-zeroconf": "^1.2.5",
|
||||||
"phonegap-plugin-barcodescanner": "^6.0.6"
|
"phonegap-plugin-barcodescanner": "^6.0.6"
|
||||||
},
|
},
|
||||||
"cordova": {
|
"cordova": {
|
||||||
@ -32,7 +34,8 @@
|
|||||||
"cordova-plugin-statusbar": {},
|
"cordova-plugin-statusbar": {},
|
||||||
"cordova-plugin-headercolor": {},
|
"cordova-plugin-headercolor": {},
|
||||||
"cordova-plugin-inappbrowser": {},
|
"cordova-plugin-inappbrowser": {},
|
||||||
"cordova-plugin-app-version": {}
|
"cordova-plugin-app-version": {},
|
||||||
|
"cordova-plugin-zeroconf": {}
|
||||||
},
|
},
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"android"
|
"android"
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="list-group">
|
||||||
|
<div class="list-group-item" onclick="openscreen('zeroconf', 'FADE')">
|
||||||
|
<b>Server Locator</b>
|
||||||
|
<p>Scan the local network for Business Apps services.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<b><span id="app_name">Netsyms Business Apps for Mobile</span> v<span id="app_version">1.x</span></b>
|
<b><span id="app_name">Netsyms Business Apps for Mobile</span> v<span id="app_version">1.x</span></b>
|
||||||
@ -40,7 +47,7 @@
|
|||||||
setnavbar("settings");
|
setnavbar("settings");
|
||||||
|
|
||||||
function deleteall() {
|
function deleteall() {
|
||||||
navigator.notification.confirm("Really wipe user data? You will need to resync the app with Portal to use it again.", function (result) {
|
navigator.notification.confirm("Really wipe user data? You will need to resync the app with AccountHub to use it again.", function (result) {
|
||||||
if (result != 1) {
|
if (result != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
61
www/views/zeroconf.html
Normal file
61
www/views/zeroconf.html
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<br />
|
||||||
|
|
||||||
|
<div class="alert alert-blue">This tool scans for Business Apps servers on the local network. Tap on a server to view it in a web browser.</div>
|
||||||
|
<div class="list-group" id="zero-list">
|
||||||
|
<div class="list-group-item" id="searching-message">
|
||||||
|
<i class="fa fa-spinner fa-spin"></i> Searching...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="btn btn-primary" onclick="stopScanning(); scanZeroconf();"><i class="fa fa-refresh"></i> Rescan</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var zeroconf = cordova.plugins.zeroconf;
|
||||||
|
zeroconf.registerAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
|
||||||
|
zeroconf.watchAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
|
||||||
|
|
||||||
|
function scanZeroconf() {
|
||||||
|
$("#searching-message").css('display', 'block');
|
||||||
|
zeroconf.watch('_http._tcp.', 'local.', function (result) {
|
||||||
|
var action = result.action;
|
||||||
|
var service = result.service;
|
||||||
|
// Ignore other services
|
||||||
|
if (typeof service.txtRecord.appid !== 'undefined' && service.txtRecord.appid == "bizappserver") {
|
||||||
|
var ipaddr = service.ipv4Addresses[0];
|
||||||
|
var divid = "#server" + ipaddr.replace(/\./gi, '');
|
||||||
|
if (action == 'added') {
|
||||||
|
console.log('service added', service);
|
||||||
|
var model = service.txtRecord.model;
|
||||||
|
if ((service.txtRecord.webprotocol == "http" || service.txtRecord.webprotocol == "https") && Number.isInteger(service.port)) {
|
||||||
|
var url = service.txtRecord.webprotocol
|
||||||
|
+ "://"
|
||||||
|
+ ipaddr
|
||||||
|
+ (service.port == 80 || service.port == 443 ? "" : ":" + service.port)
|
||||||
|
+ service.txtRecord.webpath;
|
||||||
|
var itemcontent = "<b>" + ipaddr + "</b><br />URL: " + url + "<br />Model: " + model;
|
||||||
|
if (document.getElementById(divid) == null) {
|
||||||
|
$('#zero-list').append("<div class=\"list-group-item\" id=\"" + divid + "\">" + itemcontent + "</div>");
|
||||||
|
} else {
|
||||||
|
$(divid).html(itemcontent);
|
||||||
|
}
|
||||||
|
document.getElementById(divid).onclick = function () {
|
||||||
|
window.open(url, "_system");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('service removed', service);
|
||||||
|
$(divid).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setTimeout(stopScanning, 10 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopScanning() {
|
||||||
|
zeroconf.unwatch('_http._tcp.', 'local.');
|
||||||
|
$("#searching-message").css('display', 'none');
|
||||||
|
}
|
||||||
|
|
||||||
|
setnavbar("app", "Server Locator", "settings");
|
||||||
|
scanZeroconf();
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user