Skip to content
Permalink
Browse files

增加域名解析检测

  • Loading branch information...
TLingC committed Dec 28, 2018
1 parent 6904ac4 commit c01fcb57a0ec4eddd450aa84bfc3a50198dc5302
Showing with 8 additions and 0 deletions.
  1. +8 −0 js/app.js
@@ -675,6 +675,7 @@ sampquery.prototype = {
return;
}
var that = this;
cordova.plugins.dns.resolve(that.ip, function success(address) {
chrome.sockets.udp.create(function(createInfo) {
that.socketId = createInfo.socketId;
that.listener = chrome.sockets.udp.onReceive.addListener(function(info){ that.listen(info, that.socketId, that.callback); });
@@ -684,6 +685,9 @@ sampquery.prototype = {
});
});
});
},function failure(error) {
app.dialog.alert('解析域名失败,请检查服务器设置。错误信息: ' + error);
});
},
listen: function (info, socketId, callback) {
if(info.socketId == socketId) callback(info);
@@ -795,6 +799,7 @@ function sampquery(ip, port) {
samprcon.prototype = {
send: function (data, needreply) {
var that = this;
cordova.plugins.dns.resolve(that.ip, function success(address) {
chrome.sockets.udp.create(function(createInfo) {
that.socketId = createInfo.socketId;
if(needreply) that.listener = chrome.sockets.udp.onReceive.addListener(function(info){ that.listen(info, that.socketId, that.repcallback); });
@@ -809,6 +814,9 @@ samprcon.prototype = {
});
});
});
},function failure(error) {
app.dialog.alert('解析域名失败,请检查服务器设置。错误信息: ' + error);
});
},
listen: function (info, socketId, callback) {
if(info.socketId == socketId){

0 comments on commit c01fcb5

Please sign in to comment.
You can’t perform that action at this time.