Created
July 20, 2021 23:57
-
-
Save rococtz/b82317bf1424f101616eda704082beb5 to your computer and use it in GitHub Desktop.
gun-send-receive-test
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
<html> | |
<body> | |
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/gun/lib/open.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/gun/lib/not.js"></script> | |
<div id="logger"></div> | |
<script> | |
var gun = Gun([ | |
'http://localhost:8765/gun', | |
]); | |
let message = ''; | |
let count = 0; | |
let seconds = 1; | |
setInterval(() => { | |
seconds++; | |
element.innerText = `${count} :::: ${(count / seconds).toFixed(2)}::: ${message}`; | |
}, 1000); | |
const element = document.getElementById('logger'); | |
window.onload = () => { | |
(async () => { | |
gun.get('board').on(({ myValue }) => { | |
count++; | |
message = myValue; | |
}); | |
})() | |
} | |
</script> | |
</body> | |
</html> |
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
<html> | |
<body> | |
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/gun/lib/open.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/gun/lib/not.js"></script> | |
<script> | |
var gun = Gun([ | |
'http://localhost:8765/gun', | |
]); | |
window.onload = () => { | |
(async () => { | |
const board = gun.get('board'); | |
setInterval(() => { | |
const myValue = Math.random(); | |
board.put({ myValue }); | |
}, 10) | |
})() | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment