Class: Wampproto::IdGenerator
- Inherits:
-
Object
- Object
- Wampproto::IdGenerator
- Defined in:
- lib/wampproto/id_generator.rb
Overview
ID Generator
Constant Summary collapse
- MAX_ID =
1 << 53
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ IdGenerator
constructor
A new instance of IdGenerator.
- #next ⇒ Object
Constructor Details
#initialize ⇒ IdGenerator
Returns a new instance of IdGenerator.
14 15 16 |
# File 'lib/wampproto/id_generator.rb', line 14 def initialize @id = 0 end |
Class Method Details
.generate_session_id ⇒ Object
9 10 11 |
# File 'lib/wampproto/id_generator.rb', line 9 def generate_session_id rand(1..MAX_ID) end |
Instance Method Details
#next ⇒ Object
18 19 20 21 |
# File 'lib/wampproto/id_generator.rb', line 18 def next @id = 0 if @id == MAX_ID @id += 1 end |