Skip to content

RedisRoster not calling on_signed_in event, and not removing offline users - #1

Open
mmlin wants to merge 1 commit into
mitsuhiko:masterfrom
mmlin:master
Open

RedisRoster not calling on_signed_in event, and not removing offline users#1
mmlin wants to merge 1 commit into
mitsuhiko:masterfrom
mmlin:master

Conversation

@mmlin

@mmlin mmlin commented Jun 22, 2012

Copy link
Copy Markdown

Hello mitsuhiko. These are just a couple small fixes for the RedisRoster implementation. No API changes.

I hope this helps. Great job by the way. It was really fun playing with this, and it's great to be able to use socket.io so easily with my Python apps.

on_signed_in() was never being called

In on_subcribe(), we check add a new session for the user. Afterwards, we check to see if that session was the first for that user_id. If so, we call on_signed_in(). The problem is that we whether the set is empty immediately after adding an entry--so it will never be.

r.sadd(key, data['session_id'])
if r.scard(key) == 0: # at first sign-in, this should be one, not zero
    self.on_signed_in(user_id)

We should really be checking whether there's exactly one entry, which indicates this was the first session added for that user.

The user wasn't being removed from set juggernaut-roster:online-users

This looks like a typo. Instead of removing the user from the set, we are attempting to add him instead.

r.srem(key, data['session_id'])
if r.scard(key) == 0:
    self.on_signed_out(user_id)
    r.sadd(self.key_prefix + 'online-users', user_id) # we should remove insead of add here

…o remove user from set 'juggernaut-roster:online-users'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant