Created
September 30, 2016 16:59
-
-
Save scottgarner/f420293dbc6bbfa1656a7f514ce2c929 to your computer and use it in GitHub Desktop.
Holojam send and receive though relay server.
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
<script src="http://holojam.herokuapp.com/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io.connect("https://holojam.herokuapp.com/client", | |
{ transports: ['websocket', 'polling'] } | |
); | |
socket.on('update', function (data) { | |
// Receive data from server. | |
//console.log(data); | |
}); | |
function send() { | |
// Create update packet. | |
var updateJSON = { | |
label: "perlin", | |
live_objects: [ | |
{ | |
label: "Perlin 1", | |
x: Math.random(), | |
y: Math.random(), | |
z: Math.random(), | |
qx: 0, | |
qy: 0, | |
qz: 0, | |
qw: 0, | |
} | |
] | |
} | |
// Send data back to server. | |
socket.emit("relay", updateJSON); | |
} | |
// Call send function. | |
setInterval(send, 1000); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment