Created
August 28, 2018 16:46
-
-
Save mafintosh/80638eef2bcdde14b7f17d89225fb1e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const speedometer = require('speedometer') | |
const speed = speedometer() | |
setInterval(function () { | |
console.log(speed()) | |
}, 1000) | |
const udp = chrome.sockets.udp | |
udp.create({}, function (res) { | |
const sid = res.socketId | |
udp.onReceive.addListener(function (res) { | |
speed(res.data.byteLength) | |
}) | |
udp.bind(sid, '0.0.0.0', 9999, function () { | |
console.log('bound') | |
const buf = new ArrayBuffer(1000) | |
setInterval(loop, 5) | |
function loop () { | |
udp.send(sid, buf, '159.65.107.57', 10000, noop) | |
} | |
function noop () {} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment