Skip to content

Commit

Permalink
Fixes active users
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Apr 10, 2012
1 parent 1de14a0 commit c4baac9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/active_users.rb
Expand Up @@ -18,23 +18,23 @@ def add(client_id, user)
end

def remove_by_client_id(client_id)
user_id = find_by_client_id(client_id)
user_id = find_by_client_id client_id
if user_id
@@users[user_id][:client_ids].delete client_id
if @@users[user_id][:client_ids].empty?
publish_message "disconnect", @@users[user_id][:user]
@@users.delete(user_id)
deleted_user_info = @@users.delete user_id
publish_message "disconnect", deleted_user_info[:user]
end
end
end

def remove_by_user_id(user_id)
@@users.delete(user_id)
@@users.delete user_id
end

def find_by_client_id(client_id)
@@users.each do |user_id, detail|
return user_id if detail[:client_ids].include?(client_id)
return user_id if detail[:client_ids].include? client_id
end
false
end
Expand Down

0 comments on commit c4baac9

Please sign in to comment.