Class: StompServer::StompId

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

Instance Method Summary collapse

Constructor Details

#initializeStompId

Get current hostname



17
18
19
# File 'lib/stomp_server_ng/stomp_id.rb', line 17

def initialize
  @host = Socket.gethostname.to_s
end

Instance Method Details

#[](id) ⇒ Object

Generate a ‘unique’ id based on:

  • Host name

  • Current time

  • Called supplied id



27
28
29
30
# File 'lib/stomp_server_ng/stomp_id.rb', line 27

def [](id)
  msgid = sprintf("%.6f",Time.now.to_f).to_s.sub('.','-')
  msgid = @host + '-' + msgid + '-' + id.to_s
end