Files
bbs-server/lib/repository/online_users_repository.rb
2026-04-30 09:40:14 +02:00

25 lines
404 B
Ruby

# frozen_string_literal: true
class OnlineUsersRepository
def initialize
@users = {}
@mu = Mutex.new
end
def add(session_id, name)
@mu.synchronize { @users[session_id] = name }
end
def remove(session_id)
@mu.synchronize { @users.delete(session_id) }
end
def snapshot
@mu.synchronize { @users.dup }
end
def count
@mu.synchronize { @users.size }
end
end