From 12a16abf9c178d22f4a5a3ad5d62b9f9888f8e4e Mon Sep 17 00:00:00 2001
From: "p.gurina"
Date: Thu, 8 Apr 2021 16:59:01 +0300
Subject: [PATCH 01/11] Resolve conflicts
---
.gitignore | 1 +
dist/rmbtws.js | 101 +++++++++-----------------
dist/rmbtws.min.js | 2 +-
src/RMBTControlServerCommunication.js | 101 ++++++++++----------------
4 files changed, 77 insertions(+), 128 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3dae3fd..900d4e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ docs/dist
node_modules
npm-debug.log
*.map
+package-lock.json
\ No newline at end of file
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index b052997..5b2809b 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -1385,31 +1385,19 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb
json_data['prefer_server'] = UserConf.preferredServer;
json_data['user_server_selection'] = userServerSelection;
}
- var response = void 0;
- $.ajax({
- url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource,
- type: "post",
- dataType: "json",
- contentType: "application/json",
- data: JSON.stringify(json_data),
- success: function success(data) {
- response = data;
- var config = new RMBTControlServerRegistrationResponse(data);
- onsuccess(config);
- },
- error: function error(data) {
- response = data;
- _logger.error("error getting testID");
- onerror();
- },
- complete: function complete() {
- if (_registrationCallback != null && typeof _registrationCallback === 'function') {
- _registrationCallback({
- response: response,
- request: json_data
- });
- }
- }
+
+ fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource, {
+ method: 'POST',
+ headers: headers,
+ body: JSON.stringify(json_data)
+ }).then(function (res) {
+ return res.json();
+ }).then(function (data) {
+ var config = new RMBTControlServerRegistrationResponse(data);
+ onsuccess(config);
+ }).catch(function () {
+ _logger.error("error getting testID");
+ onerror();
});
},
@@ -1418,20 +1406,17 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb
*
*/
getDataCollectorInfo: function getDataCollectorInfo() {
- $.ajax({
- url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerDataCollectorResource,
- type: "get",
- dataType: "json",
- contentType: "application/json",
- success: function success(data) {
- _rmbtTestConfig.product = data.agent.substring(0, Math.min(150, data.agent.length));
- _rmbtTestConfig.model = data.product;
- //_rmbtTestConfig.platform = data.product;
- _rmbtTestConfig.os_version = data.version;
- },
- error: function error(data) {
- _logger.error("error getting data collection response");
- }
+ fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerDataCollectorResource, {
+ method: 'GET',
+ headers: headers
+ }).then(function (res) {
+ return res.json();
+ }).then(function (data) {
+ _rmbtTestConfig.product = data.agent.substring(0, Math.min(150, data.agent.length));
+ _rmbtTestConfig.model = data.product;
+ _rmbtTestConfig.os_version = data.version;
+ }).catch(function () {
+ _logger.error("error getting data collection response");
});
},
@@ -1447,32 +1432,18 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb
var json = JSON.stringify(json_data);
_logger.debug("Submit size: " + json.length);
- var response = void 0;
- $.ajax({
- url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource,
- type: "post",
- dataType: "json",
- contentType: "application/json",
- data: json,
- success: function success(data) {
- response = data;
- _logger.debug("https://develop.netztest.at/en/Verlauf?" + json_data.test_uuid);
- //window.location.href = "https://develop.netztest.at/en/Verlauf?" + data.test_uuid;
- onsuccess(true);
- },
- error: function error(data) {
- response = data;
- _logger.error("error submitting results");
- onerror(false);
- },
- complete: function complete() {
- if (_submissionCallback !== null && typeof _submissionCallback === 'function') {
- _submissionCallback({
- response: response,
- request: json_data
- });
- }
- }
+ fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource, {
+ method: 'POST',
+ headers: headers,
+ body: json
+ }).then(function (res) {
+ return res.json();
+ }).then(function () {
+ _logger.debug(json_data.test_uuid);
+ onsuccess(true);
+ }).catch(function () {
+ _logger.error("error submitting results");
+ onerror(false);
});
}
};
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index 640561b..6934231 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -20,7 +20,7 @@
*****************************************************************************!*/
"use strict";function RMBTTest(e,t){function n(e){void 0!==w&&w===e||(w=e,M=nowMs(),E&&E(e))}function s(e,t,s){var i=(e.test_server_encryption?"wss://":"ws://")+e.test_server_address+":"+e.test_server_port;p.debug(i);var d=function(){return{IGNORE:function(){},CALLGLOBALHANDLER:function(e){e&&p.error("connection closed",e),x(RMBTError.CONNECT_FAILED)},TRYRECONNECT:function(){x(RMBTError.CONNECT_FAILED)}}}();t.onStateEnter(TestState.INIT_DOWN,function(){n(TestState.INIT_DOWN),p.debug(t.id+": start short download"),m=h,a(t,S.pretestDurationMs)}),t.onStateEnter(TestState.PING,function(){n(TestState.PING),p.debug(t.id+": starting ping"),0===t.id?u(t):t.triggerNextState()}),t.onStateEnter(TestState.DOWN,function(){if(n(TestState.DOWN),A.length>0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(h,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(L).forEach(function(e){Math.abs(r-e)t?(A.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),y[n]=u.buffer,u=null):(L.hasOwnProperty(n)||(L[n]=[]),t&&(L[n].length0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,s):p.error("unexpected error during ping test")};else{for(var r=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==_?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*a/(d/1e9))}else{var c=2*a;o<8||!y.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=h.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==_?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,h=0,_=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],L={},y={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
-"use strict";var RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.register||null,s=r.submit||null;return{obtainControlServerRegistration:function(e,r){var s={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(s,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(s.prefer_server=UserConf.preferredServer,s.user_server_selection=userServerSelection);var i=void 0;$.ajax({url:t.controlServerURL+t.controlServerRegistrationResource,type:"post",dataType:"json",contentType:"application/json",data:JSON.stringify(s),success:function(r){i=r;var t=new RMBTControlServerRegistrationResponse(r);e(t)},error:function(e){i=e,n.error("error getting testID"),r()},complete:function(){null!=o&&"function"==typeof o&&o({response:i,request:s})}})},getDataCollectorInfo:function(){$.ajax({url:t.controlServerURL+t.controlServerDataCollectorResource,type:"get",dataType:"json",contentType:"application/json",success:function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version},error:function(e){n.error("error getting data collection response")}})},submitResults:function(e,r,o){Object.assign(e,t.additionalSubmissionParameters);var i=JSON.stringify(e);n.debug("Submit size: "+i.length);var a=void 0;$.ajax({url:t.controlServerURL+t.controlServerResultResource,type:"post",dataType:"json",contentType:"application/json",data:i,success:function(t){a=t,n.debug("https://develop.netztest.at/en/Verlauf?"+e.test_uuid),r(!0)},error:function(e){a=e,n.error("error submitting results"),o(!1)},complete:function(){null!==s&&"function"==typeof s&&s({response:a,request:e})}})}}};
+"use strict";var RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};r.register,r.submit;return{obtainControlServerRegistration:function(e,r){var o={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(o,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(o.prefer_server=UserConf.preferredServer,o.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:headers,body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:headers}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,o){Object.assign(e,t.additionalSubmissionParameters);var i=JSON.stringify(e);n.debug("Submit size: "+i.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:headers,body:i}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),o(!1)})}}};
"use strict";function RMBTIntermediateResult(){}var TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}var RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.0",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n {
json_data['prefer_server'] = UserConf.preferredServer;
json_data['user_server_selection'] = userServerSelection;
}
- let response;
- $.ajax({
- url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource,
- type: "post",
- dataType: "json",
- contentType: "application/json",
- data: JSON.stringify(json_data),
- success: (data) => {
- response = data;
- let config = new RMBTControlServerRegistrationResponse(data);
- onsuccess(config);
- },
- error: (data) => {
- response = data;
- _logger.error("error getting testID");
- onerror();
- },
- complete: () => {
- if (_registrationCallback != null && typeof _registrationCallback === 'function') {
- _registrationCallback({
- response: response,
- request: json_data
- });
- }
+
+ fetch(
+ _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource,
+ {
+ method: 'POST',
+ headers,
+ body: JSON.stringify(json_data)
}
+ ).then(res => res.json()
+ ).then(data => {
+ const config = new RMBTControlServerRegistrationResponse(data);
+ onsuccess(config);
+ }).catch(() => {
+ _logger.error("error getting testID");
+ onerror();
});
},
@@ -72,20 +62,19 @@ const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
*
*/
getDataCollectorInfo: () => {
- $.ajax({
- url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerDataCollectorResource,
- type: "get",
- dataType: "json",
- contentType: "application/json",
- success: (data) => {
- _rmbtTestConfig.product = data.agent.substring(0, Math.min(150, data.agent.length));
- _rmbtTestConfig.model = data.product;
- //_rmbtTestConfig.platform = data.product;
- _rmbtTestConfig.os_version = data.version;
- },
- error: (data) => {
- _logger.error("error getting data collection response");
+ fetch(
+ _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerDataCollectorResource,
+ {
+ method: 'GET',
+ headers
}
+ ).then(res => res.json()
+ ).then(data => {
+ _rmbtTestConfig.product = data.agent.substring(0, Math.min(150, data.agent.length));
+ _rmbtTestConfig.model = data.product;
+ _rmbtTestConfig.os_version = data.version;
+ }).catch(() => {
+ _logger.error("error getting data collection response");
});
},
@@ -101,32 +90,20 @@ const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
let json = JSON.stringify(json_data);
_logger.debug("Submit size: " + json.length);
- let response;
- $.ajax({
- url: _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource,
- type: "post",
- dataType: "json",
- contentType: "application/json",
- data: json,
- success: (data) => {
- response = data;
- _logger.debug("https://develop.netztest.at/en/Verlauf?" + json_data.test_uuid);
- //window.location.href = "https://develop.netztest.at/en/Verlauf?" + data.test_uuid;
- onsuccess(true);
- },
- error: (data) => {
- response = data;
- _logger.error("error submitting results");
- onerror(false);
- },
- complete: () => {
- if (_submissionCallback !== null && typeof _submissionCallback === 'function') {
- _submissionCallback({
- response: response,
- request: json_data
- });
- }
+ fetch(
+ _rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource,
+ {
+ method: 'POST',
+ headers,
+ body: json
}
+ ).then(res => res.json()
+ ).then(() => {
+ _logger.debug(json_data.test_uuid);
+ onsuccess(true);
+ }).catch(() => {
+ _logger.error("error submitting results");
+ onerror(false);
});
}
}
From 736580046b80acd9c8cfda69b1307324f660f295 Mon Sep 17 00:00:00 2001
From: Polina Gurina
Date: Mon, 9 Dec 2024 15:46:17 +0100
Subject: [PATCH 02/11] Add exports
---
dist/rmbtws.js | 24 +++++++++++++++++++-----
dist/rmbtws.min.js | 8 ++++----
src/RMBTControlServerCommunication.js | 5 ++---
src/TestDatastructures.js | 2 +-
src/Websockettest.js | 2 +-
src/WebsockettestDatastructures.js | 2 +-
6 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index 5b2809b..9ec0fbb 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -27,6 +27,10 @@
* @returns {}
*/
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.RMBTTest = RMBTTest;
function RMBTTest(rmbtTestConfig, rmbtControlServer) {
var _server_override = "wss://developv4-rmbtws.netztest.at:19002";
@@ -1345,6 +1349,9 @@ if (typeof window.setCookie === 'undefined') {
}
"use strict";
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
/**
* Handles the communication with the ControlServer
* @param rmbtTestConfig RMBT Test Configuratio
@@ -1353,13 +1360,14 @@ if (typeof window.setCookie === 'undefined') {
* 'submit': Function to be called after result submission: function(event)
* @returns Object
*/
-var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmbtTestConfig, options) {
+var RMBTControlServerCommunication = exports.RMBTControlServerCommunication = function RMBTControlServerCommunication(rmbtTestConfig, options) {
var _rmbtTestConfig = rmbtTestConfig;
var _logger = log.getLogger("rmbtws");
options = options || {};
- var _registrationCallback = options.register || null;
- var _submissionCallback = options.submit || null;
+ var _options = options,
+ headers = _options.headers;
+
return {
/**
@@ -1450,7 +1458,10 @@ var RMBTControlServerCommunication = function RMBTControlServerCommunication(rmb
};
"use strict";
-var TestEnvironment = function () {
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var TestEnvironment = exports.TestEnvironment = function () {
var testVisualization = null;
var geoTracker = null;
@@ -1596,7 +1607,10 @@ var TestVisualization = function () {
}();
"use strict";
-var RMBTTestConfig = function () {
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var RMBTTestConfig = exports.RMBTTestConfig = function () {
RMBTTestConfig.prototype.version = "0.3"; //minimal version compatible with the test
RMBTTestConfig.prototype.language;
RMBTTestConfig.prototype.uuid = "";
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index 6934231..f7d71b9 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -18,11 +18,11 @@
* The source code for this project is available at
* https://github.com/rtr-nettest/rmbtws
*****************************************************************************!*/
-"use strict";function RMBTTest(e,t){function n(e){void 0!==w&&w===e||(w=e,M=nowMs(),E&&E(e))}function s(e,t,s){var i=(e.test_server_encryption?"wss://":"ws://")+e.test_server_address+":"+e.test_server_port;p.debug(i);var d=function(){return{IGNORE:function(){},CALLGLOBALHANDLER:function(e){e&&p.error("connection closed",e),x(RMBTError.CONNECT_FAILED)},TRYRECONNECT:function(){x(RMBTError.CONNECT_FAILED)}}}();t.onStateEnter(TestState.INIT_DOWN,function(){n(TestState.INIT_DOWN),p.debug(t.id+": start short download"),m=h,a(t,S.pretestDurationMs)}),t.onStateEnter(TestState.PING,function(){n(TestState.PING),p.debug(t.id+": starting ping"),0===t.id?u(t):t.triggerNextState()}),t.onStateEnter(TestState.DOWN,function(){if(n(TestState.DOWN),A.length>0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(h,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(L).forEach(function(e){Math.abs(r-e)t?(A.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),y[n]=u.buffer,u=null):(L.hasOwnProperty(n)||(L[n]=[]),t&&(L[n].length0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,s):p.error("unexpected error during ping test")};else{for(var r=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==_?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*a/(d/1e9))}else{var c=2*a;o<8||!y.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=h.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==_?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,h=0,_=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],L={},y={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,s):p.error("unexpected error during ping test")};else{for(var r=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*a/(d/1e9))}else{var c=2*a;o<8||!L.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
-"use strict";var RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};r.register,r.submit;return{obtainControlServerRegistration:function(e,r){var o={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(o,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(o.prefer_server=UserConf.preferredServer,o.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:headers,body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:headers}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,o){Object.assign(e,t.additionalSubmissionParameters);var i=JSON.stringify(e);n.debug("Submit size: "+i.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:headers,body:i}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),o(!1)})}}};
-"use strict";function RMBTIntermediateResult(){}var TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r,i=o.headers;return{obtainControlServerRegistration:function(e,r){var o={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(o,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(o.prefer_server=UserConf.preferredServer,o.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:i,body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:i}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,o){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:i,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),o(!1)})}}};
+"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
-"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}var RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.0",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n {
+export const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
const _rmbtTestConfig = rmbtTestConfig;
const _logger = log.getLogger("rmbtws");
options = options || {};
- let _registrationCallback = options.register || null;
- let _submissionCallback = options.submit || null;
+ const { headers } = options;
return {
/**
diff --git a/src/TestDatastructures.js b/src/TestDatastructures.js
index 64eda54..a36f859 100644
--- a/src/TestDatastructures.js
+++ b/src/TestDatastructures.js
@@ -1,6 +1,6 @@
"use strict";
-const TestEnvironment = (function () {
+export const TestEnvironment = (function () {
let testVisualization = null;
let geoTracker = null;
diff --git a/src/Websockettest.js b/src/Websockettest.js
index dd49391..3023634 100644
--- a/src/Websockettest.js
+++ b/src/Websockettest.js
@@ -26,7 +26,7 @@
* @param {RMBTControlServerCommunication} rmbtControlServer
* @returns {}
*/
-function RMBTTest(rmbtTestConfig, rmbtControlServer) {
+export function RMBTTest(rmbtTestConfig, rmbtControlServer) {
const _server_override = "wss://developv4-rmbtws.netztest.at:19002";
let _logger = log.getLogger("rmbtws");
diff --git a/src/WebsockettestDatastructures.js b/src/WebsockettestDatastructures.js
index 4fccfb4..7a5da6c 100644
--- a/src/WebsockettestDatastructures.js
+++ b/src/WebsockettestDatastructures.js
@@ -1,6 +1,6 @@
"use strict";
-let RMBTTestConfig = (function () {
+export let RMBTTestConfig = (function () {
RMBTTestConfig.prototype.version = "0.3"; //minimal version compatible with the test
RMBTTestConfig.prototype.language;
RMBTTestConfig.prototype.uuid = "";
From 7dd61684a6fd9b50ccdcc70428f6a9d0ca11bb6d Mon Sep 17 00:00:00 2001
From: Polina Gurina
Date: Mon, 9 Dec 2024 15:59:10 +0100
Subject: [PATCH 03/11] Fix headers
---
src/RMBTControlServerCommunication.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/RMBTControlServerCommunication.js b/src/RMBTControlServerCommunication.js
index bc0d8e3..a75af4e 100644
--- a/src/RMBTControlServerCommunication.js
+++ b/src/RMBTControlServerCommunication.js
@@ -11,7 +11,9 @@ export const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
const _logger = log.getLogger("rmbtws");
options = options || {};
- const { headers } = options;
+ const headers = options.headers || {
+ 'Content-Type': 'application/json'
+ };
return {
/**
From ba6d9d62c89e41fcc07738a3a9a707aea909b572 Mon Sep 17 00:00:00 2001
From: Polina Gurina
Date: Mon, 9 Dec 2024 15:59:35 +0100
Subject: [PATCH 04/11] Build
---
dist/rmbtws.js | 8 ++++----
dist/rmbtws.min.js | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index 7199824..f4635db 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -1356,7 +1356,7 @@ if (typeof window.setCookie === 'undefined') {
document.cookie = cookie_name + "=" + c_value + " path=/;";
};
}
-"use strict";
+'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
@@ -1374,9 +1374,9 @@ var RMBTControlServerCommunication = exports.RMBTControlServerCommunication = fu
var _logger = log.getLogger("rmbtws");
options = options || {};
- var _options = options,
- headers = _options.headers;
-
+ var headers = options.headers || {
+ 'Content-Type': 'application/json'
+ };
return {
/**
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index 7c920a2..c43cfc8 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -20,7 +20,7 @@
*****************************************************************************!*/
"use strict";function RMBTTest(e,t){function n(e){void 0!==w&&w===e||(w=e,M=nowMs(),E&&E(e))}function s(e,t,s){var a=(e.test_server_encryption?"wss://":"ws://")+e.test_server_address+":"+e.test_server_port;p.debug(a);var d=function(){return{IGNORE:function(){},CALLGLOBALHANDLER:function(e){e&&p.error("connection closed",e),x(RMBTError.CONNECT_FAILED)},TRYRECONNECT:function(){x(RMBTError.CONNECT_FAILED)}}}();t.onStateEnter(TestState.INIT_DOWN,function(){n(TestState.INIT_DOWN),p.debug(t.id+": start short download"),m=_,i(t,S.pretestDurationMs)}),t.onStateEnter(TestState.PING,function(){n(TestState.PING),p.debug(t.id+": starting ping"),0===t.id?u(t):t.triggerNextState()}),t.onStateEnter(TestState.DOWN,function(){if(n(TestState.DOWN),A.length>0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var i=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*i/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(i=Math.min(2*i,v),u())})}()}function a(e,t,n,s){var o=e.socket,r=t,i=m*t,a=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),a+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var i=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(i),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,i=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function a(){g(e,o,i,function(u){if(r+=o*i,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*i/(d/1e9))}else{var c=2*i;o<8||!L.hasOwnProperty(c)||!I?(o*=2,a()):(i=Math.min(2*i,v),a())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",i))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
-"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r,i=o.headers;return{obtainControlServerRegistration:function(e,r){var o={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(o,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(o.prefer_server=UserConf.preferredServer,o.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:i,body:JSON.stringify(o)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:i}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,o){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:i,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),o(!1)})}}};
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),i(!1)})}}};
"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var RMBTTestConfig=exports.RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.1",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.doPingIntervalMilliseconds=-1,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n
Date: Mon, 9 Dec 2024 19:11:26 +0100
Subject: [PATCH 05/11] Add pings to intermediateResult
---
dist/rmbtws.js | 3 +++
dist/rmbtws.min.js | 4 ++--
src/TestDatastructures.js | 1 +
src/Websockettest.js | 2 ++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index f4635db..52300a9 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -275,6 +275,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
if (_rmbtTestResult !== null) {
if (_intermediateResult.status === TestState.PING || _intermediateResult.status === TestState.DOWN) {
_intermediateResult.pingNano = _rmbtTestResult.ping_server_median;
+ _intermediateResult.pings = _rmbtTestResult.pings;
}
if (_intermediateResult.status === TestState.DOWN || _intermediateResult.status == TestState.INIT_UP) {
@@ -688,6 +689,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
var onsuccess = function onsuccess(pingResult) {
thread.result.pings.push(pingResult);
+ _rmbtTestResult.pings.push(pingResult);
//use first two pings to do a better approximation of the remaining time
if (pingsRemaining === _rmbtTestConfig.numPings - 1) {
@@ -1545,6 +1547,7 @@ RMBTIntermediateResult.prototype.progress = 0;
RMBTIntermediateResult.prototype.downBitPerSecLog = -1;
RMBTIntermediateResult.prototype.upBitPerSecLog = -1;
RMBTIntermediateResult.prototype.remainingWait = -1;
+RMBTIntermediateResult.prototype.pings = [];
"use strict";
/**
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index c43cfc8..3c56a1e 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -18,10 +18,10 @@
* The source code for this project is available at
* https://github.com/rtr-nettest/rmbtws
*****************************************************************************!*/
-"use strict";function RMBTTest(e,t){function n(e){void 0!==w&&w===e||(w=e,M=nowMs(),E&&E(e))}function s(e,t,s){var a=(e.test_server_encryption?"wss://":"ws://")+e.test_server_address+":"+e.test_server_port;p.debug(a);var d=function(){return{IGNORE:function(){},CALLGLOBALHANDLER:function(e){e&&p.error("connection closed",e),x(RMBTError.CONNECT_FAILED)},TRYRECONNECT:function(){x(RMBTError.CONNECT_FAILED)}}}();t.onStateEnter(TestState.INIT_DOWN,function(){n(TestState.INIT_DOWN),p.debug(t.id+": start short download"),m=_,i(t,S.pretestDurationMs)}),t.onStateEnter(TestState.PING,function(){n(TestState.PING),p.debug(t.id+": starting ping"),0===t.id?u(t):t.triggerNextState()}),t.onStateEnter(TestState.DOWN,function(){if(n(TestState.DOWN),A.length>0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var i=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*i/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(i=Math.min(2*i,v),u())})}()}function a(e,t,n,s){var o=e.socket,r=t,i=m*t,a=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),a+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var i=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(i),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,i=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function a(){g(e,o,i,function(u){if(r+=o*i,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*i/(d/1e9))}else{var c=2*i;o<8||!L.hasOwnProperty(c)||!I?(o*=2,a()):(i=Math.min(2*i,v),a())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",i))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var i=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*i/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(i=Math.min(2*i,v),u())})}()}function a(e,t,n,s){var o=e.socket,r=t,i=m*t,a=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),a+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var i=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(i),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,i=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function a(){g(e,o,i,function(u){if(r+=o*i,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*i/(d/1e9))}else{var c=2*i;o<8||!L.hasOwnProperty(c)||!I?(o*=2,a()):(i=Math.min(2*i,v),a())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",i))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),i(!1)})}}};
-"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
+"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1,RMBTIntermediateResult.prototype.pings=[];
"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var RMBTTestConfig=exports.RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.1",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.doPingIntervalMilliseconds=-1,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n
Date: Mon, 9 Dec 2024 19:29:30 +0100
Subject: [PATCH 06/11] Add pings to intermediateResult
---
dist/rmbtws.js | 4 +---
dist/rmbtws.min.js | 4 ++--
src/TestDatastructures.js | 1 -
src/Websockettest.js | 3 +--
4 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index 52300a9..f6faf81 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -275,7 +275,6 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
if (_rmbtTestResult !== null) {
if (_intermediateResult.status === TestState.PING || _intermediateResult.status === TestState.DOWN) {
_intermediateResult.pingNano = _rmbtTestResult.ping_server_median;
- _intermediateResult.pings = _rmbtTestResult.pings;
}
if (_intermediateResult.status === TestState.DOWN || _intermediateResult.status == TestState.INIT_UP) {
@@ -689,7 +688,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
var onsuccess = function onsuccess(pingResult) {
thread.result.pings.push(pingResult);
- _rmbtTestResult.pings.push(pingResult);
+ _rmbtTestResult.ping_server_median = pingResult.server;
//use first two pings to do a better approximation of the remaining time
if (pingsRemaining === _rmbtTestConfig.numPings - 1) {
@@ -1547,7 +1546,6 @@ RMBTIntermediateResult.prototype.progress = 0;
RMBTIntermediateResult.prototype.downBitPerSecLog = -1;
RMBTIntermediateResult.prototype.upBitPerSecLog = -1;
RMBTIntermediateResult.prototype.remainingWait = -1;
-RMBTIntermediateResult.prototype.pings = [];
"use strict";
/**
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index 3c56a1e..662d767 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -18,10 +18,10 @@
* The source code for this project is available at
* https://github.com/rtr-nettest/rmbtws
*****************************************************************************!*/
-"use strict";function RMBTTest(e,t){function n(e){void 0!==w&&w===e||(w=e,M=nowMs(),E&&E(e))}function s(e,t,s){var a=(e.test_server_encryption?"wss://":"ws://")+e.test_server_address+":"+e.test_server_port;p.debug(a);var d=function(){return{IGNORE:function(){},CALLGLOBALHANDLER:function(e){e&&p.error("connection closed",e),x(RMBTError.CONNECT_FAILED)},TRYRECONNECT:function(){x(RMBTError.CONNECT_FAILED)}}}();t.onStateEnter(TestState.INIT_DOWN,function(){n(TestState.INIT_DOWN),p.debug(t.id+": start short download"),m=_,i(t,S.pretestDurationMs)}),t.onStateEnter(TestState.PING,function(){n(TestState.PING),p.debug(t.id+": starting ping"),0===t.id?u(t):t.triggerNextState()}),t.onStateEnter(TestState.DOWN,function(){if(n(TestState.DOWN),A.length>0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var i=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*i/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(i=Math.min(2*i,v),u())})}()}function a(e,t,n,s){var o=e.socket,r=t,i=m*t,a=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),a+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var i=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(i),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,i=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function a(){g(e,o,i,function(u){if(r+=o*i,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*i/(d/1e9))}else{var c=2*i;o<8||!L.hasOwnProperty(c)||!I?(o*=2,a()):(i=Math.min(2*i,v),a())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",i))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var i=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*i/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(i=Math.min(2*i,v),u())})}()}function a(e,t,n,s){var o=e.socket,r=t,i=m*t,a=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),a+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var i=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(i),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,i=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function a(){g(e,o,i,function(u){if(r+=o*i,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*i/(d/1e9))}else{var c=2*i;o<8||!L.hasOwnProperty(c)||!I?(o*=2,a()):(i=Math.min(2*i,v),a())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",i))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),i(!1)})}}};
-"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1,RMBTIntermediateResult.prototype.pings=[];
+"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var RMBTTestConfig=exports.RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.1",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.doPingIntervalMilliseconds=-1,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n
Date: Tue, 10 Dec 2024 00:57:09 +0100
Subject: [PATCH 07/11] Add pings to intermediateResult
---
src/Websockettest.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Websockettest.js b/src/Websockettest.js
index 553aa0a..9d6f18b 100644
--- a/src/Websockettest.js
+++ b/src/Websockettest.js
@@ -281,6 +281,7 @@ export function RMBTTest(rmbtTestConfig, rmbtControlServer) {
if (_rmbtTestResult !== null) {
if (_intermediateResult.status === TestState.PING || _intermediateResult.status === TestState.DOWN) {
_intermediateResult.pingNano = _rmbtTestResult.ping_server_median;
+ _intermediateResult.pings = _rmbtTestResult.pings;
}
if (_intermediateResult.status === TestState.DOWN || _intermediateResult.status == TestState.INIT_UP) {
@@ -696,7 +697,7 @@ export function RMBTTest(rmbtTestConfig, rmbtControlServer) {
const onsuccess = function(pingResult) {
thread.result.pings.push(pingResult);
- _rmbtTestResult.ping_server_median = pingResult.server;
+ _rmbtTestResult.pings = [...thread.result.pings];
//use first two pings to do a better approximation of the remaining time
if (pingsRemaining === (_rmbtTestConfig.numPings - 1)) {
From 42f8360298adf1405d2e23b9455df5c4decf4148 Mon Sep 17 00:00:00 2001
From: Polina Gurina
Date: Tue, 10 Dec 2024 00:57:23 +0100
Subject: [PATCH 08/11] Build
---
dist/rmbtws.js | 6 +++++-
dist/rmbtws.min.js | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index f6faf81..e7de987 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -31,6 +31,9 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RMBTTest = RMBTTest;
+
+function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+
function RMBTTest(rmbtTestConfig, rmbtControlServer) {
var _server_override = "wss://developv4-rmbtws.netztest.at:19002";
@@ -275,6 +278,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
if (_rmbtTestResult !== null) {
if (_intermediateResult.status === TestState.PING || _intermediateResult.status === TestState.DOWN) {
_intermediateResult.pingNano = _rmbtTestResult.ping_server_median;
+ _intermediateResult.pings = _rmbtTestResult.pings;
}
if (_intermediateResult.status === TestState.DOWN || _intermediateResult.status == TestState.INIT_UP) {
@@ -688,7 +692,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
var onsuccess = function onsuccess(pingResult) {
thread.result.pings.push(pingResult);
- _rmbtTestResult.ping_server_median = pingResult.server;
+ _rmbtTestResult.pings = [].concat(_toConsumableArray(thread.result.pings));
//use first two pings to do a better approximation of the remaining time
if (pingsRemaining === _rmbtTestConfig.numPings - 1) {
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index 662d767..246a2ab 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -18,7 +18,7 @@
* The source code for this project is available at
* https://github.com/rtr-nettest/rmbtws
*****************************************************************************!*/
-"use strict";function RMBTTest(e,t){function n(e){void 0!==w&&w===e||(w=e,M=nowMs(),E&&E(e))}function s(e,t,s){var a=(e.test_server_encryption?"wss://":"ws://")+e.test_server_address+":"+e.test_server_port;p.debug(a);var d=function(){return{IGNORE:function(){},CALLGLOBALHANDLER:function(e){e&&p.error("connection closed",e),x(RMBTError.CONNECT_FAILED)},TRYRECONNECT:function(){x(RMBTError.CONNECT_FAILED)}}}();t.onStateEnter(TestState.INIT_DOWN,function(){n(TestState.INIT_DOWN),p.debug(t.id+": start short download"),m=_,i(t,S.pretestDurationMs)}),t.onStateEnter(TestState.PING,function(){n(TestState.PING),p.debug(t.id+": starting ping"),0===t.id?u(t):t.triggerNextState()}),t.onStateEnter(TestState.DOWN,function(){if(n(TestState.DOWN),A.length>0){var s=r(A,S.downloadThreadsLimitsMbit,!1);D=s.numThreads,I&&(m=s.chunkSize),A=[]}t.id0){var s=r(A,S.uploadThreadsLimitsMbit,!0);C=s.numThreads,I&&(m=s.chunkSize),A=[]}t.ide&&(o=t[e])}),o=Math.min(U,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var i=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(A.push(o*i/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(i=Math.min(2*i,v),u())})}()}function a(e,t,n,s){var o=e.socket,r=t,i=m*t,a=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),a+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var i=[],a=0;a=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(i),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,i=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function a(){g(e,o,i,function(u){if(r+=o*i,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));A.push(o*i/(d/1e9))}else{var c=2*i;o<8||!L.hasOwnProperty(c)||!I?(o*=2,a()):(i=Math.min(2*i,v),a())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",i))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:N.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:N.pings,test_bytes_download:N.bytes_download,test_bytes_upload:N.bytes_upload,test_nsec_download:N.nsec_download,test_nsec_upload:N.nsec_upload,test_num_threads:D,num_threads_ul:C,test_ping_shortest:N.ping_server_shortest,test_speed_download:N.speed_download,test_speed_upload:N.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:N.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:N.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,N=null,b=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},B=null,U=0,D=0,C=0,A=[],G=0;this.onError=function(e){b=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==b){var t=b;b=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),N=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){U=parseInt(e.test_numthreads),B=new CyclicBarrier(U),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),N.beginTime=Date.now();for(var t=0;t0){var s=r(D,S.downloadThreadsLimitsMbit,!1);C=s.numThreads,I&&(m=s.chunkSize),D=[]}t.id0){var s=r(D,S.uploadThreadsLimitsMbit,!0);U=s.numThreads,I&&(m=s.chunkSize),D=[]}t.ide&&(o=t[e])}),o=Math.min(B,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(D.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var a=[],i=0;i=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));D.push(o*a/(d/1e9))}else{var c=2*a;o<8||!L.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:b.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:b.pings,test_bytes_download:b.bytes_download,test_bytes_upload:b.bytes_upload,test_nsec_download:b.nsec_download,test_nsec_upload:b.nsec_upload,test_num_threads:C,num_threads_ul:U,test_ping_shortest:b.ping_server_shortest,test_speed_download:b.speed_download,test_speed_upload:b.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:b.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:b.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,b=null,N=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},A=null,B=0,C=0,U=0,D=[],G=0;this.onError=function(e){N=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==N){var t=N;N=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),b=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){B=parseInt(e.test_numthreads),A=new CyclicBarrier(B),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),b.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),i(!1)})}}};
"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
From 91af7e116cb5a466effebb1ed5fa77655dcaac5c Mon Sep 17 00:00:00 2001
From: Polina Gurina
Date: Tue, 10 Dec 2024 12:31:07 +0100
Subject: [PATCH 09/11] Put back callbacks
---
src/RMBTControlServerCommunication.js | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/RMBTControlServerCommunication.js b/src/RMBTControlServerCommunication.js
index a75af4e..eb97b38 100644
--- a/src/RMBTControlServerCommunication.js
+++ b/src/RMBTControlServerCommunication.js
@@ -41,6 +41,7 @@ export const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
json_data['user_server_selection'] = userServerSelection;
}
+ let response
fetch(
_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource,
{
@@ -50,11 +51,20 @@ export const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
}
).then(res => res.json()
).then(data => {
+ response = data;
const config = new RMBTControlServerRegistrationResponse(data);
onsuccess(config);
- }).catch(() => {
+ }).catch(reason => {
+ response = reason;
_logger.error("error getting testID");
onerror();
+ }).finally(() => {
+ if (_registrationCallback != null && typeof _registrationCallback === 'function') {
+ _registrationCallback({
+ response: response,
+ request: json_data
+ });
+ }
});
},
@@ -91,6 +101,8 @@ export const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
let json = JSON.stringify(json_data);
_logger.debug("Submit size: " + json.length);
+
+ let response;
fetch(
_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource,
{
@@ -99,12 +111,21 @@ export const RMBTControlServerCommunication = (rmbtTestConfig, options) => {
body: json
}
).then(res => res.json()
- ).then(() => {
+ ).then((data) => {
+ response = data;
_logger.debug(json_data.test_uuid);
onsuccess(true);
- }).catch(() => {
+ }).catch((reason) => {
+ response = reason;
_logger.error("error submitting results");
onerror(false);
+ }).finally(() => {
+ if (_submissionCallback !== null && typeof _submissionCallback === 'function') {
+ _submissionCallback({
+ response: response,
+ request: json_data
+ });
+ }
});
}
}
From 9b46154c6511f07fb9631ed84954d936cd533565 Mon Sep 17 00:00:00 2001
From: Polina Gurina
Date: Tue, 10 Dec 2024 12:32:41 +0100
Subject: [PATCH 10/11] Build
---
dist/rmbtws.js | 27 ++++++++++++++++++++++++---
dist/rmbtws.min.js | 2 +-
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index e7de987..cc3b3ce 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -1408,6 +1408,7 @@ var RMBTControlServerCommunication = exports.RMBTControlServerCommunication = fu
json_data['user_server_selection'] = userServerSelection;
}
+ var response = void 0;
fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerRegistrationResource, {
method: 'POST',
headers: headers,
@@ -1415,11 +1416,20 @@ var RMBTControlServerCommunication = exports.RMBTControlServerCommunication = fu
}).then(function (res) {
return res.json();
}).then(function (data) {
+ response = data;
var config = new RMBTControlServerRegistrationResponse(data);
onsuccess(config);
- }).catch(function () {
+ }).catch(function (reason) {
+ response = reason;
_logger.error("error getting testID");
onerror();
+ }).finally(function () {
+ if (_registrationCallback != null && typeof _registrationCallback === 'function') {
+ _registrationCallback({
+ response: response,
+ request: json_data
+ });
+ }
});
},
@@ -1454,18 +1464,29 @@ var RMBTControlServerCommunication = exports.RMBTControlServerCommunication = fu
var json = JSON.stringify(json_data);
_logger.debug("Submit size: " + json.length);
+
+ var response = void 0;
fetch(_rmbtTestConfig.controlServerURL + _rmbtTestConfig.controlServerResultResource, {
method: 'POST',
headers: headers,
body: json
}).then(function (res) {
return res.json();
- }).then(function () {
+ }).then(function (data) {
+ response = data;
_logger.debug(json_data.test_uuid);
onsuccess(true);
- }).catch(function () {
+ }).catch(function (reason) {
+ response = reason;
_logger.error("error submitting results");
onerror(false);
+ }).finally(function () {
+ if (_submissionCallback !== null && typeof _submissionCallback === 'function') {
+ _submissionCallback({
+ response: response,
+ request: json_data
+ });
+ }
});
}
};
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index 246a2ab..c209b35 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -20,7 +20,7 @@
*****************************************************************************!*/
"use strict";function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0){var s=r(D,S.downloadThreadsLimitsMbit,!1);C=s.numThreads,I&&(m=s.chunkSize),D=[]}t.id0){var s=r(D,S.uploadThreadsLimitsMbit,!0);U=s.numThreads,I&&(m=s.chunkSize),D=[]}t.ide&&(o=t[e])}),o=Math.min(B,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(D.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var a=[],i=0;i=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));D.push(o*a/(d/1e9))}else{var c=2*a;o<8||!L.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:b.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:b.pings,test_bytes_download:b.bytes_download,test_bytes_upload:b.bytes_upload,test_nsec_download:b.nsec_download,test_nsec_upload:b.nsec_upload,test_num_threads:C,num_threads_ul:U,test_ping_shortest:b.ping_server_shortest,test_speed_download:b.speed_download,test_speed_upload:b.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:b.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:b.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,b=null,N=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},A=null,B=0,C=0,U=0,D=[],G=0;this.onError=function(e){N=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==N){var t=N;N=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),b=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){B=parseInt(e.test_numthreads),A=new CyclicBarrier(B),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),b.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
-"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection),fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(){n.error("error getting testID"),r()})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length),fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(){n.debug(e.test_uuid),r(!0)}).catch(function(){n.error("error submitting results"),i(!1)})}}};
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection);var s=void 0;fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){s=r;var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(e){s=e,n.error("error getting testID"),r()}).finally(function(){null!=_registrationCallback&&"function"==typeof _registrationCallback&&_registrationCallback({response:s,request:i})})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length);var a=void 0;fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(t){a=t,n.debug(e.test_uuid),r(!0)}).catch(function(e){a=e,n.error("error submitting results"),i(!1)}).finally(function(){null!==_submissionCallback&&"function"==typeof _submissionCallback&&_submissionCallback({response:a,request:e})})}}};
"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var RMBTTestConfig=exports.RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.1",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.doPingIntervalMilliseconds=-1,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n
Date: Wed, 11 Dec 2024 15:59:22 +0100
Subject: [PATCH 11/11] Add open_test_uuid to updateInfo
---
dist/rmbtws.js | 4 ++--
dist/rmbtws.min.js | 4 ++--
src/TestVisualization.js | 2 +-
src/Websockettest.js | 3 ++-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/dist/rmbtws.js b/dist/rmbtws.js
index cc3b3ce..7ba2881 100644
--- a/dist/rmbtws.js
+++ b/dist/rmbtws.js
@@ -162,7 +162,7 @@ function RMBTTest(rmbtTestConfig, rmbtControlServer) {
//@TODO: Nicer
//if there is testVisualization, make use of it!
if (TestEnvironment.getTestVisualization() !== null) {
- TestEnvironment.getTestVisualization().updateInfo(response.test_server_name, response.client_remote_ip, response.provider, response.test_uuid);
+ TestEnvironment.getTestVisualization().updateInfo(response.test_server_name, response.client_remote_ip, response.provider, response.test_uuid, response.open_test_uuid);
}
var continuation = function continuation() {
@@ -1603,7 +1603,7 @@ var TestVisualization = function () {
* @param providerName
* @param testUUID
*/
- TestVisualization.prototype.updateInfo = function (serverName, remoteIp, providerName, testUUID) {};
+ TestVisualization.prototype.updateInfo = function (serverName, remoteIp, providerName, testUUID, openTestUUID) {};
/**
* Will be called from Websockettest as soon as the current status changes
diff --git a/dist/rmbtws.min.js b/dist/rmbtws.min.js
index c209b35..591f6b5 100644
--- a/dist/rmbtws.min.js
+++ b/dist/rmbtws.min.js
@@ -18,11 +18,11 @@
* The source code for this project is available at
* https://github.com/rtr-nettest/rmbtws
*****************************************************************************!*/
-"use strict";function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0){var s=r(D,S.downloadThreadsLimitsMbit,!1);C=s.numThreads,I&&(m=s.chunkSize),D=[]}t.id0){var s=r(D,S.uploadThreadsLimitsMbit,!0);U=s.numThreads,I&&(m=s.chunkSize),D=[]}t.ide&&(o=t[e])}),o=Math.min(B,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(D.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var a=[],i=0;i=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));D.push(o*a/(d/1e9))}else{var c=2*a;o<8||!L.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:b.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:b.pings,test_bytes_download:b.bytes_download,test_bytes_upload:b.bytes_upload,test_nsec_download:b.nsec_download,test_nsec_upload:b.nsec_upload,test_num_threads:C,num_threads_ul:U,test_ping_shortest:b.ping_server_shortest,test_speed_download:b.speed_download,test_speed_upload:b.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:b.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:b.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,b=null,N=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},A=null,B=0,C=0,U=0,D=[],G=0;this.onError=function(e){N=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==N){var t=N;N=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),b=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){B=parseInt(e.test_numthreads),A=new CyclicBarrier(B),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),b.beginTime=Date.now();for(var t=0;t0){var s=r(D,S.downloadThreadsLimitsMbit,!1);C=s.numThreads,I&&(m=s.chunkSize),D=[]}t.id0){var s=r(D,S.uploadThreadsLimitsMbit,!0);U=s.numThreads,I&&(m=s.chunkSize),D=[]}t.ide&&(o=t[e])}),o=Math.min(B,o),p.debug("set number of threads to be used in upcoming speed test to: "+o);var r=G/(1e3/(S.measurementPointsTimespan/2));if(r-=r%1024,r=Math.max(_,r),r=Math.min(v,r),p.debug("calculated chunksize for upcoming speed test "+r/1024+" KB"),n){var a=Number.POSITIVE_INFINITY;Object.keys(y).forEach(function(e){Math.abs(r-e)t?(D.push(o*a/(d/1e9)),e.socket.onmessage=n):o<8||!I?(o*=2,u()):(a=Math.min(2*a,v),u())})}()}function i(e,t,n,s){var o=e.socket,r=t,a=m*t,i=0,u=null,d=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},c=function(e){if("string"!=typeof e.data){var t=!1;u=null===u?new Uint8Array(e.data):d(u,new Uint8Array(e.data)),i+=e.data.byteLength,u.length===n&&(r--,t=!0),t&&255===u[u.length-1]?(o.onmessage=function(e){var t=e.data;s(t)},o.send("OK\n"),L[n]=u.buffer,u=null):(y.hasOwnProperty(n)||(y[n]=[]),t&&(y[n].length0&&0===n){performance.now()-s0)e.socket.onmessage=function(t){"ACCEPT GETCHUNKS GETTIME PUT PUTNORESULT PING QUIT\n"===t.data?d(e,o):p.error("unexpected error during ping test")};else{for(var a=[],i=0;i=255&&(p.debug(e.id+": received end chunk"),window.clearInterval(a),e.socket.onmessage=function(t){p.debug(t.data),e.socket.onmessage=n},e.socket.send("OK\n"))}},S.measurementPointsTimespan);var c=function(e){o++,s+=e.data.byteLength,d=nowNs(),u=e.data};e.socket.onmessage=c;var l=nowNs();e.socket.send("GETTIME "+t+(m!==h?" "+m:"")+"\n")}function l(e,t){var n=e.socket.onmessage,s=nowMs(),o=1,r=0,a=m;window.setTimeout(function(){var e=nowMs(),n=e-s;p.debug("diff:"+(n-t)+" ("+(n-t)/t+" %)")},t);!function i(){g(e,o,a,function(u){if(r+=o*a,p.debug(e.id+": "+u),nowMs()-s>t){e.socket.onmessage=n;var d=parseInt(u.substring(5));D.push(o*a/(d/1e9))}else{var c=2*a;o<8||!L.hasOwnProperty(c)||!I?(o*=2,i()):(a=Math.min(2*a,v),i())}})}()}function g(e,t,n,s){var o=e.socket;o.onmessage=function(e){0!==e.data.indexOf("OK")&&0!==e.data.indexOf("ACCEPT")&&s(e.data)},p.debug(e.id+": uploading "+t+" chunks, "+n*t/1e3+" KB"),o.send("PUTNORESULT"+(I?" "+n:"")+"\n");for(var r=0;rf&&(c=o.duration,e.result.up.push(o))}else null!==(s=_.exec(t.data))&&(u=!0,p.debug("Upload duration: "+s[1]),e.socket.onmessage=n,document.removeEventListener("visibilitychange",a))};e.socket.onmessage=I,e.socket.send("PUT"+(m!==h?" "+m:"")+"\n")}function f(e){return{client_language:"de",client_name:S.client,client_uuid:S.uuid,client_version:S.client_version,client_software_version:S.client_software_version,geoLocations:b.geoLocations,model:S.model,network_type:98,platform:S.platform,product:S.product,pings:b.pings,test_bytes_download:b.bytes_download,test_bytes_upload:b.bytes_upload,test_nsec_download:b.nsec_download,test_nsec_upload:b.nsec_upload,test_num_threads:C,num_threads_ul:U,test_ping_shortest:b.ping_server_shortest,test_speed_download:b.speed_download,test_speed_upload:b.speed_upload,test_token:e.test_token,test_uuid:e.test_uuid,time:b.beginTime,timezone:S.timezone,type:"DESKTOP",version_code:"1",speed_detail:b.speedItems,user_server_selection:S.userServerSelection}}var p=log.getLogger("rmbtws"),m=null,v=4194304,_=0,h=4096,I=!1,S=void 0,k=void 0,b=null,N=null,E=null,w=TestState.INIT,M=null,O={durationInitMs:2500,durationPingMs:1e4,durationUpMs:-1,durationDownMs:-1},P=new RMBTIntermediateResult,R=[],y={},L={},A=null,B=0,C=0,U=0,D=[],G=0;this.onError=function(e){N=e},this.onStateChange=function(e){E=e};var x=function(e){if(p.debug("error occurred during websocket test:",e),e!==RMBTError.NOT_SUPPORTED&&n(TestState.ERROR),null!==N){var t=N;N=null,t(e)}};this.startTest=function(){if(void 0===window.WebSocket)return void x(RMBTError.NOT_SUPPORTED);n(TestState.INIT),b=new RMBTTestResult,k.getDataCollectorInfo(),k.obtainControlServerRegistration(function(e){B=parseInt(e.test_numthreads),A=new CyclicBarrier(B),O.durationDownMs=1e3*e.test_duration,O.durationUpMs=1e3*e.test_duration,null!==TestEnvironment.getTestVisualization()&&TestEnvironment.getTestVisualization().updateInfo(e.test_server_name,e.client_remote_ip,e.provider,e.test_uuid,e.open_test_uuid);var t=function(){p.debug("got geolocation, obtaining token and websocket address");var t=function(){n(TestState.INIT),b.beginTime=Date.now();for(var t=0;t0&&r.long>0&&testVisualization.setLocation(r.lat,r.long)}else i.innerHTML=Lang.getString("NotSupported");return void runCallback()}runCallback(),TestEnvironment.getGeoTracker().start(function(o,e){if(!0!==o)if(e)switch(e.code){case e.PERMISSION_DENIED:i.innerHTML=Lang.getString("NoPermission");break;case e.TIMEOUT:break;case e.POSITION_UNAVAILABLE:i.innerHTML=Lang.getString("NotAvailable");break;case e.UNKNOWN_ERROR:i.innerHTML=Lang.getString("NotAvailable")+"("+e.code+")"}else i.innerHTML=Lang.getString("NotAvailable")},TestEnvironment.getTestVisualization())}var curGeoPos=void 0,geo_callback=void 0,loc_timeout=void 0,GeoTracker=function(){function o(){e=[],a=!1}var e=void 0,t=void 0,n=null,i=void 0,a=void 0;o.prototype.start=function(o,l){if(t=o,void 0!==l&&(n=l),navigator.geolocation)navigator.geolocation.getCurrentPosition(function(o){0===e.length&&(a=!0,r(o))},c,{enableHighAccuracy:!1,timeout:2e3,maximumAge:6e4}),i=navigator.geolocation.watchPosition(r,c,{enableHighAccuracy:!0,timeout:1/0,maximumAge:0});else{var u=t;t=null,u(!1)}window.setTimeout(function(){c()},2e3)};var r=function(o){if(1===e.length&&a&&(e=[],a=!1),e.push({geo_lat:o.coords.latitude,geo_long:o.coords.longitude,accuracy:o.coords.accuracy,altitude:o.coords.altitude,bearing:o.coords.heading,speed:o.coords.speed,tstamp:o.timestamp,provider:"Browser"}),null!==t){var i=t;t=null,i(!0)}null!==n&&n.setLocation(o.coords.latitude,o.coords.longitude),l(o)},c=function(o){if(null!==t){var e=t;t=null,e(!1,o)}},l=function(o){var e={};e.lat=o.coords.latitude,e.long=o.coords.longitude,e.accuracy=o.coords.accuracy,e.altitude=o.coords.altitude,e.heading=o.coords.heading,e.speed=o.coords.speed,e.tstamp=o.timestamp,e=JSON.stringify(e),setCookie("coords",e,3600)};return o.prototype.stop=function(){navigator.geolocation&&navigator.geolocation.clearWatch(i)},o.prototype.getResults=function(){var o=null;return e=e.filter(function(e){return null==o?(o=e,!0):!Object.keys(e).every(function(t){return o.hasOwnProperty(t)&&o[t]===e[t]})&&(o=e,!0)})},o}();void 0===window.setCookie&&(window.setCookie=function(o,e,t){var n=new Date,i=n.getTime();i+=1e3*t,n.setTime(i);var a=encodeURIComponent(e)+(null==t?";":"; expires="+n.toUTCString()+";");document.cookie=o+"="+a+" path=/;"});
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var RMBTControlServerCommunication=exports.RMBTControlServerCommunication=function(e,r){var t=e,n=log.getLogger("rmbtws");r=r||{};var o=r.headers||{"Content-Type":"application/json"};return{obtainControlServerRegistration:function(e,r){var i={version:t.version,language:t.language,uuid:t.uuid,type:t.type,version_code:t.version_code,client:t.client,timezone:t.timezone,time:(new Date).getTime()};Object.assign(i,t.additionalRegistrationParameters),"undefined"!=typeof userServerSelection&&userServerSelection>0&&"undefined"!=typeof UserConf&&void 0!==UserConf.preferredServer&&"default"!==UserConf.preferredServer&&(i.prefer_server=UserConf.preferredServer,i.user_server_selection=userServerSelection);var s=void 0;fetch(t.controlServerURL+t.controlServerRegistrationResource,{method:"POST",headers:o,body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(r){s=r;var t=new RMBTControlServerRegistrationResponse(r);e(t)}).catch(function(e){s=e,n.error("error getting testID"),r()}).finally(function(){null!=_registrationCallback&&"function"==typeof _registrationCallback&&_registrationCallback({response:s,request:i})})},getDataCollectorInfo:function(){fetch(t.controlServerURL+t.controlServerDataCollectorResource,{method:"GET",headers:o}).then(function(e){return e.json()}).then(function(e){t.product=e.agent.substring(0,Math.min(150,e.agent.length)),t.model=e.product,t.os_version=e.version}).catch(function(){n.error("error getting data collection response")})},submitResults:function(e,r,i){Object.assign(e,t.additionalSubmissionParameters);var s=JSON.stringify(e);n.debug("Submit size: "+s.length);var a=void 0;fetch(t.controlServerURL+t.controlServerResultResource,{method:"POST",headers:o,body:s}).then(function(e){return e.json()}).then(function(t){a=t,n.debug(e.test_uuid),r(!0)}).catch(function(e){a=e,n.error("error submitting results"),i(!1)}).finally(function(){null!==_submissionCallback&&"function"==typeof _submissionCallback&&_submissionCallback({response:a,request:e})})}}};
"use strict";function RMBTIntermediateResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var TestEnvironment=exports.TestEnvironment=function(){var e=null,t=null;return{getTestVisualization:function(){return e},getGeoTracker:function(){return t},init:function(r,n){void 0===r&&(r=new TestVisualization),void 0===n&&(n=new GeoTracker),e=r,t=n}}}(),TestState={WAIT:"WAIT",INIT:"INIT",INIT_DOWN:"INIT_DOWN",PING:"PING",DOWN:"DOWN",CONNECT_UPLOAD:"CONNECT_UPLOAD",INIT_UP:"INIT_UP",UP:"UP",END:"END",ERROR:"ERROR",ABORTED:"ABORTED",LOCATE:"LOCATE",LOCABORTED:"LOCABORTED",SPEEDTEST_END:"SPEEDTEST_END",QOS_TEST_RUNNING:"QOS_TEST_RUNNING",QOS_END:"QOS_END"};RMBTIntermediateResult.prototype.setLogValues=function(){var e=function(e){return e<1e4?0:(2+Math.log(e/1e6/Math.LN10))/4};this.downBitPerSecLog=e(downBitPerSec),this.upBitPerSecLog=e(upBitPerSec)},RMBTIntermediateResult.prototype.pingNano=-1,RMBTIntermediateResult.prototype.downBitPerSec=-1,RMBTIntermediateResult.prototype.upBitPerSec=-1,RMBTIntermediateResult.prototype.status=TestState.INIT,RMBTIntermediateResult.prototype.progress=0,RMBTIntermediateResult.prototype.downBitPerSecLog=-1,RMBTIntermediateResult.prototype.upBitPerSecLog=-1,RMBTIntermediateResult.prototype.remainingWait=-1;
-"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
+"use strict";var TestVisualization=function(){function t(t,s){this.successCallback=t,this.errorCallback=s}return t.prototype.setRMBTTest=function(t){},t.prototype.updateInfo=function(t,s,a,c,o){},t.prototype.setStatus=function(t){if("ERROR"===t||"ABORTED"===t){if(this.errorCallback){var s=this.errorCallback;this.errorCallback=null,s()}}else if("END"===t&&null!==_successCallback){var s=this.successCallback;this.successCallback=null,s()}},t.prototype.setLocation=function(t,s){},t.prototype.startTest=function(){},t}();
"use strict";function RMBTTestThread(t){var e=log.getLogger("rmbtws"),o={},s=t;return{setState:function(t){this.state=t,e.debug(this.id+": reached state: "+t);var r=this;s.await(function(){if(e.debug(r.id+": all threads reached state: "+t),void 0!==o[t]&&null!==o[t]){(0,o[t])()}else e.info(r.id+": no callback registered for state: "+t)})},onStateEnter:function(t,e){o[t]=e},retriggerState:function(){setState(this.state)},triggerNextState:function(){var t=[TestState.INIT,TestState.INIT_DOWN,TestState.PING,TestState.DOWN,TestState.CONNECT_UPLOAD,TestState.INIT_UP,TestState.UP,TestState.END];if(this.state!==TestState.END){var o=t[t.indexOf(this.state)+1];e.debug(this.id+": triggered state "+o),this.setState(o)}},id:-1,socket:null,result:new RMBTThreadTestResult}}function RMBTTestResult(){this.pings=[],this.speedItems=[],this.threads=[]}function RMBTThreadTestResult(){this.down=[],this.up=[],this.pings=[]}function RMBTPingResult(){}Object.defineProperty(exports,"__esModule",{value:!0});var RMBTTestConfig=exports.RMBTTestConfig=function(){function t(t,e,o){this.language=t,this.controlServerURL=e+"/"+o,"undefined"!=typeof Intl&&Intl.DateTimeFormat().resolvedOptions().timeZone&&(this.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone.replace("Europe/Berlin","Europe/Vienna"))}return t.prototype.version="0.3",t.prototype.language,t.prototype.uuid="",t.prototype.type="DESKTOP",t.prototype.version_code="0.3",t.prototype.client_version="0.3",t.prototype.client_software_version="0.9.1",t.prototype.os_version=1,t.prototype.platform="RMBTws",t.prototype.model="Websocket",t.prototype.product="Chrome",t.prototype.client="RMBTws",t.prototype.timezone="Europe/Vienna",t.prototype.controlServerURL,t.prototype.controlServerRegistrationResource="/testRequest",t.prototype.controlServerResultResource="/result",t.prototype.controlServerDataCollectorResource="/requestDataCollector",t.prototype.pretestDurationMs=2e3,t.prototype.savedChunks=4,t.prototype.measurementPointsTimespan=40,t.prototype.numPings=10,t.prototype.doPingIntervalMilliseconds=-1,t.prototype.downloadThreadsLimitsMbit={0:1,1:3,100:5},t.prototype.uploadThreadsLimitsMbit={0:1,30:2,80:3,150:5},t.prototype.userServerSelection=void 0!==window.userServerSelection?userServerSelection:0,t.prototype.additionalRegistrationParameters={},t.prototype.additionalSubmissionParameters={},t}(),RMBTControlServerRegistrationResponse=function(){function t(t){Object.assign(this,t),this.test_duration=parseInt(t.test_duration)}return t.prototype.client_remote_ip,t.prototype.provider,t.prototype.test_server_encryption="",t.prototype.test_numthreads,t.prototype.test_server_name,t.prototype.test_uuid,t.prototype.test_id,t.prototype.test_token,t.prototype.test_server_address,t.prototype.test_duration,t.prototype.result_url,t.prototype.test_wait,t.prototype.test_server_port,t}();RMBTTestResult.prototype.addThread=function(t){this.threads.push(t)},RMBTTestResult.prototype.ip_local=null,RMBTTestResult.prototype.ip_server=null,RMBTTestResult.prototype.port_remote=null,RMBTTestResult.prototype.num_threads=null,RMBTTestResult.prototype.encryption="NONE",RMBTTestResult.prototype.ping_shortest=-1,RMBTTestResult.prototype.ping_median=-1,RMBTTestResult.prototype.client_version=null,RMBTTestResult.prototype.pings=[],RMBTTestResult.prototype.speed_download=-1,RMBTTestResult.prototype.speed_upload=-1,RMBTTestResult.prototype.speedItems=[],RMBTTestResult.prototype.bytes_download=-1,RMBTTestResult.prototype.nsec_download=-1,RMBTTestResult.prototype.bytes_upload=-1,RMBTTestResult.prototype.nsec_upload=-1,RMBTTestResult.prototype.totalDownBytes=-1,RMBTTestResult.prototype.totalUpBytes=-1,RMBTTestResult.prototype.beginTime=-1,RMBTTestResult.prototype.geoLocations=[],RMBTTestResult.calculateOverallSpeedFromMultipleThreads=function(t,e){for(var o=t.length,s=1/0,r=0;r0&&p[p.length-1].duration0){for(var d=u,T=0;T=s){d=T;break}var R=void 0;if(l[d].duration===s)R=l[u-1].bytes;else{var y=0===d?0:l[d-1].bytes,h=l[d].bytes,c=h-y,v=0===d?0:l[d-1].duration,g=l[d].duration,_=g-v,M=s-v,B=M/_,f=Math.round(c*B);f<0&&(f=0),R=y+f}n+=R}}return{bytes:n,nsec:s,speed:8*n/(s/1e9)}},RMBTTestResult.prototype.calculateAll=function(){for(var t=0;t0)for(var o=0;o0)for(var n=0;n