You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ the Heroku WebSocket Beta announcement at [blog.heroku.com/archives/2013/10/8/we
12
12
13
13
When the client is first run in the browser, a [UUID](https://github.com/broofa/node-uuid#readme) token is generated and stored in a cookie which is passed to the server in the headers of each WebSocket message. This gives the server a consistent way to identify each user.
14
14
15
-
The client uses the [browser's geolocation API](https://www.google.com/search?q=browser%20geolocation%20api) and the [geolocation-stream](https://github.com/maxogden/geolocation-stream#readme) node module to determine the user's physical location, continually listening for location updates in realtime. EOnce the WebSocket connection is establised, the client broadcasts its location to the server:
15
+
The client uses the [browser's geolocation API](https://www.google.com/search?q=browser%20geolocation%20api) and the [geolocation-stream](https://github.com/maxogden/geolocation-stream#readme) node module to determine the user's physical location, continually listening for location updates in realtime. Once the WebSocket connection is established, the client broadcasts its location to the server:
16
16
17
17
```js
18
18
{
@@ -31,6 +31,15 @@ The client then listens for messages from the server, rendering and removing mar
31
31
32
32
The server was designed with horizontal scalability in mind. The shared location dataset is stored in a redis datastore and each web dyno connects to this shared resource to pull the complete list of pins to place on the map. Clients viewing the map each establish their own WebSocket connection to any one of the backend web dynos and receive real-time updates as locations are added and removed from the redis datastore.
33
33
34
+
When the server receives a message from a client, it adds the client's location data to the Redis store (or updates if it's already present), using the combined client's URL/UUID pair as the Redis key:
The server then fetches all keys from Redis that match that URL and broadcasts the update
41
+
to all connected clients at that same URL.
42
+
34
43
### Embedding the Javscript Client on Your Site
35
44
36
45
The Geosockets JavasScript client can be used on any website:
@@ -57,7 +66,7 @@ If you're new to Heroku or Node.js development, you'll need to install a few thi
57
66
58
67
1.[Heroku Toolbelt](https://toolbelt.heroku.com), which gives you git, foreman, and the heroku command-line interface.
59
68
1.[Node.js](http://nodejs.org/)
60
-
1.[redis](http://redis.io/). If you're using [homebrew](http://brew.sh/), install with `brew install redis`
69
+
1.[Redis](http://redis.io/). If you're using [homebrew](http://brew.sh/), install with `brew install redis`
61
70
62
71
Clone the repo and install npm dependencies:
63
72
@@ -83,7 +92,7 @@ behavior in production without exposing your site visitors to debugging data.
83
92
84
93
### Testing
85
94
86
-
Crude integration testing is done with [CasperJS](http://casperjs.org/), a navigation scripting & testing utility for [PhantomJS](http://phantomjs.org/). Casper is integrated into the app using the [grunt-casper](https://github.com/iamchrismiller/grunt-casper) plugin, and run with foreman. Each time you make a change to your client, the casper tests are run automatically.
95
+
Basic integration testing is done with [CasperJS](http://casperjs.org/), a navigation scripting & testing utility for [PhantomJS](http://phantomjs.org/). Casper is integrated into the app using the [grunt-casper](https://github.com/iamchrismiller/grunt-casper) plugin, and run with foreman. Each time you make a change to your client, the casper tests are run automatically.
0 commit comments