level 1
Game_Interpreter.prototype.getYourIP = function() {
//BUG:仅联网软件有效,单机游戏默认显示"局域网"
//#返回值里含空格,还不能用==号判断要用方法:.includes/.contains(stringxx)
var RTCPeerConnection = window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
if (RTCPeerConnection) (function () {
var rtc = new RTCPeerConnection({iceServers:[]});
if (1 || window.mozRTCPeerConnection) {
rtc.createDataChannel('', {reliable:false});
};
rtc.onicecandidate = function (evt) {
//手册里找不到这个方法!?,难道是内置的周期方法??(这个方法也使用了)
if (evt.candidate) grepSDP("a="+evt.candidate.candidate);
};
rtc.createOffer(function (offerDesc) {
grepSDP(offerDesc.sdp);
rtc.setLocalDescription(offerDesc);
}, function (e) { console.warn("offer failed", e); });
//并行处理的简写()
var addrs = Object.create(null);
addrs["0.0.0.0"] = false;
function updateDisplay(newAddr) {
if (newAddr in addrs) return;
else addrs[newAddr] = true;
var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
for(var i = 0; i < displayAddrs.length; i++){
if(displayAddrs[i].length > 16){
displayAddrs.splice(i, 1);
i--;
}
}
if (displayAddrs[0]) hsyIp(displayAddrs[0]);
// alert("ip: " + displayAddrs[0])
//有效,但获取需要几秒时间,所以必须前缀if
//BUG:在事件--脚本中使用要等待 半s左右(不等待会跳过一次事件)...
}
function grepSDP(sdp) {
var hosts = [];






