From 1c6ad5c8f8cc29b29788550251ecf2ef23e55fad Mon Sep 17 00:00:00 2001 From: genxium Date: Sat, 21 Jan 2023 23:03:55 +0800 Subject: [PATCH] Minor fix. --- .../assets/plugin_scripts/NetworkDoctor.js | 66 ------------------- .../plugin_scripts/NetworkDoctor.js.meta | 9 --- 2 files changed, 75 deletions(-) delete mode 100644 frontend/assets/plugin_scripts/NetworkDoctor.js delete mode 100644 frontend/assets/plugin_scripts/NetworkDoctor.js.meta diff --git a/frontend/assets/plugin_scripts/NetworkDoctor.js b/frontend/assets/plugin_scripts/NetworkDoctor.js deleted file mode 100644 index 7c07733..0000000 --- a/frontend/assets/plugin_scripts/NetworkDoctor.js +++ /dev/null @@ -1,66 +0,0 @@ -function NetworkDoctor(serverFps, clientUpsyncFps) { - this.serverFps = serverFps; - this.clientUpsyncFps = clientUpsyncFps; - this.millisPerServerFrame = parseInt(1000 / this.serverFps); - this._tooLongSinceLastFrameDiffReceivedThreshold = (this.millisPerServerFrame << 6); - - this.setupFps = function(fps) { - this.serverFps = this.clientUpsyncFps = fps; - this.millisPerServerFrame = parseInt(1000 / this.serverFps); - this._tooLongSinceLastFrameDiffReceivedThreshold = (this.millisPerServerFrame << 6); - } - - this._lastFrameDiffRecvTime = null; - this._tooLongSinceLastFrameDiffReceived = function() { - if (undefined === this._lastFrameDiffRecvTime || null === this._lastFrameDiffRecvTime) return false; - return (this._tooLongSinceLastFrameDiffReceivedThreshold <= (Date.now() - this._lastFrameDiffRecvTime)); - }; - - this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0; - this._consecutiveALittleLongFrameDiffReceivedIntervalCountThreshold = 120; - - this.onNewFrameDiffReceived = function(frameDiff) { - var now = Date.now(); - if (undefined !== this._lastFrameDiffRecvTime && null !== this._lastFrameDiffRecvTime) { - var intervalFromLastFrameDiff = (now - this._lastFrameDiffRecvTime); - if ((this.millisPerServerFrame << 5) < intervalFromLastFrameDiff) { - ++this._consecutiveALittleLongFrameDiffReceivedIntervalCount; - console.log('Medium delay, intervalFromLastFrameDiff is', intervalFromLastFrameDiff); - } else { - this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0; - } - } - this._lastFrameDiffRecvTime = now; - }; - - this._networkComplaintPrefix = "\nNetwork is not good >_<\n"; - - this.generateNetworkComplaint = function(excludeTypeConstantALittleLongFrameDiffReceivedInterval, excludeTypeTooLongSinceLastFrameDiffReceived) { - if (this.hasBattleStopped) return null; - var shouldComplain = false; - var ret = this._networkComplaintPrefix; - if (true != excludeTypeConstantALittleLongFrameDiffReceivedInterval && this._consecutiveALittleLongFrameDiffReceivedIntervalCountThreshold <= this._consecutiveALittleLongFrameDiffReceivedIntervalCount) { - this._consecutiveALittleLongFrameDiffReceivedIntervalCount = 0; - ret += "\nConstantly having a little long recv interval.\n"; - shouldComplain = true; - } - if (true != excludeTypeTooLongSinceLastFrameDiffReceived && this._tooLongSinceLastFrameDiffReceived()) { - ret += "\nToo long since last received frameDiff.\n"; - shouldComplain = true; - } - return (shouldComplain ? ret : null); - }; - - this.hasBattleStopped = false; - this.onBattleStopped = function() { - this.hasBattleStopped = true; - }; - - this.isClientSessionConnected = function() { - if (!window.game) return false; - if (!window.game.clientSession) return false; - return window.game.clientSession.connected; - }; -} - -window.NetworkDoctor = NetworkDoctor; diff --git a/frontend/assets/plugin_scripts/NetworkDoctor.js.meta b/frontend/assets/plugin_scripts/NetworkDoctor.js.meta deleted file mode 100644 index ed88779..0000000 --- a/frontend/assets/plugin_scripts/NetworkDoctor.js.meta +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ver": "1.0.5", - "uuid": "477c07c3-0d50-4d55-96f0-6eaf9f25e2da", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file