diff --git a/data/result.go b/data/result.go index 36bb1571..ad2eaa0e 100644 --- a/data/result.go +++ b/data/result.go @@ -45,4 +45,5 @@ type NDTResult struct { // ndt7 Upload *model.ArchivalData `json:",omitempty"` Download *model.ArchivalData `json:",omitempty"` + Ping *model.ArchivalData `json:",omitempty"` } diff --git a/html/ndt7-ping.js b/html/ndt7-ping.js new file mode 100644 index 00000000..b2ed6c04 --- /dev/null +++ b/html/ndt7-ping.js @@ -0,0 +1,22 @@ +/* jshint esversion: 6, asi: true, worker: true */ +// WebWorker that runs the ndt7 ping test +onmessage = function (ev) { + 'use strict' + let url = new URL(ev.data.href) + url.protocol = (url.protocol === 'https:') ? 'wss:' : 'ws:' + url.pathname = '/ndt/v7/ping' + const sock = new WebSocket(url.toString(), 'net.measurementlab.ndt.v7') + sock.onclose = function () { + postMessage(null) + } + sock.onopen = function () { + sock.onmessage = function (ev) { + if (!(ev.data instanceof Blob)) { + let m = JSON.parse(ev.data) + m.Origin = 'server' + m.Test = 'ping' + postMessage(m) + } + } + } +} diff --git a/html/ndt7.html b/html/ndt7.html index e5e18742..548355c1 100644 --- a/html/ndt7.html +++ b/html/ndt7.html @@ -24,8 +24,10 @@