-
-
Save ToeJamson/0b050e10be974cbbdd0d to your computer and use it in GitHub Desktop.
Proximity Chat
This file contains 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
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | |
// Geo Hash | |
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | |
function geohash( coord, resolution ) { | |
var rez = Math.pow( 10, resolution || 0 ); | |
return Math.floor(coord * rez) / rez; | |
} |
This file contains 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
// Create Proximity Channel | |
channel = geohash( pos.latitude, 0 ) + '' + geohash( pos.longitude, 0 ); |
This file contains 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
// 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