-
-
Save chappjc/b1116518aecf46f5d087846c7f03774d to your computer and use it in GitHub Desktop.
Test page that connects to the insight socket.io backend and logs new transactions and blocks.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
</head> | |
<body> | |
<script src="http://localhost:7777/js/socket.io.slim.js"></script> | |
<script> | |
var socket = io('http://localhost:7777', {path: '/insight/socket.io', transports: ['websocket'], upgrade: false}); | |
//var socket = io('https://mainnet.decred.org/') | |
socket.on('connect', function() { | |
socket.emit('subscribe', 'inv'); | |
socket.emit('subscribe', 'sync'); | |
socket.emit('subscribe', 'Dcur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx'); | |
}) | |
socket.on('tx', function(data) { | |
console.log("New transaction received: " + JSON.stringify(data, null, 4)) | |
}) | |
socket.on('block', function(data) { | |
console.log("New block received: " + JSON.stringify(data, null, 4)) | |
}) | |
socket.on('Dcur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx', function(data) { | |
console.log("Dcur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx: " + JSON.stringify(data, null, 4)) | |
}) | |
socket.on('status', function(data) { | |
console.log("Status: " + JSON.stringify(data, null, 4)) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment