Skip to content

Instantly share code, notes, and snippets.

@StanShumsky
Forked from ToeJamson/1.js
Last active August 29, 2015 14:21
Show Gist options
  • Save StanShumsky/f4837c89cdf1e17373b5 to your computer and use it in GitHub Desktop.
Save StanShumsky/f4837c89cdf1e17373b5 to your computer and use it in GitHub Desktop.
$scope.subscribe = function() {
...
PubNub.ngSubscribe({
channel: theChannel,
state: {
"firstName" : $scope.user.firstName,
"lastName" : $scope.user.lastName,
"favoriteColor" : $scope.user.faveColor
}
});
...
}
PubNub.ngState({
channel:theChannel,
state: {
"firstName":$scope.user.firstName,
"lastName":$scope.user.lastName,
"lat":$scope.user.position.lat,
"lon":$scope.user.position.lon
}
});
PubNub.ngSubscribe({ channel: theChannel });
...
$rootScope.$on(PubNub.ngPrsEv(theChannel), function(event, payload) {
// event is AngularJS event, payload contains PubNub Presence event
console.log('got a presence event:', payload);
});
...
PubNub.ngHereNow({ channel: theChannel });
PubNub.ngSubscribe({ channel: theChannel });
PubNub.ngHereNow({ channel: theChannel });
...
allTheUsers = PubNub.ngListPresence(theChannel);
PubNub.ngSubscribe({ channel: theChannel });
PubNub.ngHereNow({ channel: theChannel });
...
$rootScope.$on(PubNub.ngPrsEv(theChannel), function(event, payload) {
$scope.userList = PubNub.ngListPresence(theChannel);
});
PubNub.ngSubscribe({ channel: theChannel });
PubNub.ngHereNow({ channel: theChannel });
...
$rootScope.$on(PubNub.ngPrsEv(theChannel), function(event, payload) {
$scope.userDataMap = PubNub.ngPresenceData(theChannel);
});
PubNub.ngWhereNow({
uuid:theUserId,
callback:function(){console.log(arguments)}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment