-
hookbox notes
last modified January 18, 2011 by egj
Setting a username
conn = hookbox.connect("http://localhost:2974", [cookieString])
If cookieString is not passed, all the current cookies will be sent and passed on to the web app's endpoint. So to let the user set his own username (for example) you could pass that --
var username = prompt("What's your name?");conn = hookbox.connect(path, "username="+username);
And on the server:
def connect(self, req):username = req.cookies['username']
return [True, {"name": username}]
Presence updates
conn.onSubscribed = function(channelName, subscription) { var allUsersHereIncludingSelf = subscription.presence; subscription.onSubscribe = function(frame) { var newUser = frame.user; }; subscription.onUnsubscribe = function(frame) { var userWhoLeft = frame.user; }; };
Ok!