Skip to content

Commit

Permalink
many: start session ID at 1, dont keep track
Browse files Browse the repository at this point in the history
  • Loading branch information
om26er committed May 11, 2024
1 parent 041171c commit 8dd0f63
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/wampproto/id_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ module Wampproto
class IdGenerator
MAX_ID = 1 << 53

@ids = {}
class << self
def generate_session_id
id = rand(100_000..MAX_ID)
if @ids.include?(id)
generate_session_id
else
@ids[id] = id
end
rand(1..MAX_ID)
end
end

Expand All @@ -24,9 +18,8 @@ def initialize
def next
if @id == MAX_ID
@id = 0
else
@id += 1
end
@id += 1
end
end
end

0 comments on commit 8dd0f63

Please sign in to comment.