Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Created May 6, 2014 21:26
Show Gist options
  • Save ToeJamson/0b050e10be974cbbdd0d to your computer and use it in GitHub Desktop.
Save ToeJamson/0b050e10be974cbbdd0d to your computer and use it in GitHub Desktop.
Proximity Chat
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Geo Hash
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function geohash( coord, resolution ) {
var rez = Math.pow( 10, resolution || 0 );
return Math.floor(coord * rez) / rez;
}
// Create Proximity Channel
channel = geohash( pos.latitude, 0 ) + '' + geohash( pos.longitude, 0 );
// Connect to Proximity Channel
pubnub.subscribe({
channel : channel,
message : receive,
connect : ready,
presence : presence
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment