Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Tile38 from browser with websockets

Tile38 from browser with websockets

Create the files index.html and socket.js

<html>
  <head>
    <meta charset="utf-8">
    <title>index</title>
  </head>
  <body>
    <script src="socket.js" type="text/javascript" charset="utf-8"></script>
  </body>
</html>

socket.js

var socket = new WebSocket("ws://localhost:9851/nearby+people+fence+roam+people+*+5000");

socket.onmessage = function(event) {
  console.log(event.data);
};

In tile38-cli add "people"

SET people bob POINT 33.01 -115.01
SET people alice POINT 33.02 -115.02

In browser console you will get the output

{"command":"set","group":"586bd85af4fef1144799c759","detect":"roam","key":"people","time":"2017-01-03T13:59:06.610766558-03:00","id":"bob","object":{"type":"Point","coordinates":[-115.01,33.01]},"nearby":{"key":"people","id":"alice","meters":1451.138152186708}}

References

<html>
<head>
<meta charset="utf-8">
<title>index</title>
</head>
<body>
<script src="js/socket.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
var socket = new WebSocket("ws://localhost:9851/nearby+people+fence+roam+people+*+5000");
socket.onmessage = function(event) {
console.log(event.data);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment