Class: StompServer::SessionIDManager

Inherits:
Object
  • Object
show all
Defined in:
lib/stomp_server_ng.rb

Overview

session ID cache manager

Constant Summary collapse

@@session_cache =
nil
@@generator =
nil

Class Method Summary collapse

Class Method Details

.dump_cache(logger) ⇒ Object



53
54
55
56
57
58
# File 'lib/stomp_server_ng.rb', line 53

def self.dump_cache(logger)
  logger.debug("Session ID Dump:")
  @@session_cache.each do |sessid|
    logger.debug("#{sessid}")
  end
end

.get_cache_id(requested_size) ⇒ Object



47
48
49
50
51
# File 'lib/stomp_server_ng.rb', line 47

def self.get_cache_id(requested_size)
  session_id = @@session_cache.pop
  initialize_cache(requested_size) if @@session_cache.size == 0
  session_id
end

.initialize_cache(requested_size) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/stomp_server_ng.rb', line 29

def self.initialize_cache(requested_size)
  #
  return [] if requested_size <= 0
  #
  @@session_cache = @@session_cache || []
  #
  if not @@generator
    UUID::state_file = "./.temp_uuid_state"
    @@generator = UUID::new()
  end
  #
  return @@session_cache if @@session_cache.size > requested_size
  #
  (requested_size - @@session_cache.size).times do
    @@session_cache << @@generator.generate
  end
end