Created
May 29, 2018 05:03
-
-
Save neopunisher/a0bdb7dd19ba112bda30e73a34f260da to your computer and use it in GitHub Desktop.
ultrasonicsoundcontrol
This file contains hidden or 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
(function(url, inj) { | |
inj(url).then(function() { | |
var ALPHABET = '0123456789'; | |
var MESSAGE = '314159'; | |
var button = document.createElement('button'); | |
document.body.appendChild(button) | |
button.addEventListener('click', onButton); | |
function onButton() { | |
ssocket = new sonicnet.Sender({alphabet: ALPHABET, charDuration: 0.2}); | |
ssocket.send(MESSAGE); | |
} | |
// On some other machine: | |
sserver = new sonicnet.Receiver({alphabet: ALPHABET}); | |
sserver.on('message', function(message) { | |
// message is '31415'. Do something with it. | |
console.log(message); | |
}); | |
sserver.start(); | |
}) | |
})('https://wzrd.in/standalone/sonicnet@latest', (src, head = true) => new Promise(function(c, d) { | |
var a = document.createElement("script"); | |
a.src = src; | |
a.type = "text/javascript"; | |
a.onload = c; | |
a.onerror = d; | |
document[head ? 'head' : 'body'].appendChild(a) | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment