Skip to content

Instantly share code, notes, and snippets.

@minakhan01
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minakhan01/97212819eb1cf58ae120 to your computer and use it in GitHub Desktop.
Save minakhan01/97212819eb1cf58ae120 to your computer and use it in GitHub Desktop.
[wearscript] pub_subs.html
<!-- WearScript on Glass/Android -->
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function main() {
if (WS.scriptVersion(1)) return;
WS.say('Welcome to WearScript');
WS.serverConnect('{{WSUrl}}', function () {
WS.subscribe('pong', function (chan, timestamp0, timestamp1, groupDevice) {
WS.log('Pong: ' + groupDevice + ': Remote - Glass0: ' + (timestamp1 - timestamp0) + ' Glass1 - Glass0: ' + (((new Date).getTime() / 1000) - timestamp0));
});
setInterval(function () {
WS.publish('ping', 'pong', (new Date).getTime() / 1000);
WS.log('in ping publish: '+(new Date).getTime() / 1000);
}, 250);
});
}
window.onload = main;
</script></body></html>
{"name":"Example"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment