Skip to content

Instantly share code, notes, and snippets.

@scottgarner
Created September 30, 2016 16:59
Show Gist options
  • Save scottgarner/f420293dbc6bbfa1656a7f514ce2c929 to your computer and use it in GitHub Desktop.
Save scottgarner/f420293dbc6bbfa1656a7f514ce2c929 to your computer and use it in GitHub Desktop.
Holojam send and receive though relay server.
<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