Created
February 9, 2014 21:27
-
-
Save bwhite/8906171 to your computer and use it in GitHub Desktop.
[wearscript] Example using the subscribe functionality
This file contains hidden or 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 style="width:100%; height:100%; overflow:hidden"> | |
| <head><script src="https://api.picar.us/wearscriptdev/bower_components/msgpack-javascript/msgpack.js"></script></head> | |
| <script> | |
| /* To use, try the following in the playground (HACK_WS may change by then, but use w/e it is now) | |
| HACK_WS.publish('example', 'test'); | |
| HACK_WS.publish('example', 'test', {'1': 3}); | |
| */ | |
| function example(data) { | |
| WS.log(JSON.stringify(msgpack.unpack(atob(data)))); | |
| } | |
| function server() { | |
| WS.subscribe('example', 'example'); | |
| } | |
| function main() { | |
| if (WS.scriptVersion(1)) return; | |
| WS.serverConnect('{{WSUrl}}', 'server'); | |
| } | |
| window.onload = main; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment