Class: StompServer::StompFrame

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command = nil, headers = nil, body = nil) ⇒ StompFrame

Returns a new instance of StompFrame.



5
6
7
8
9
10
11
12
# File 'lib/stomp_server_ng/stomp_frame.rb', line 5

def initialize(command=nil, headers=nil, body=nil)
  @command = command
  @headers = headers || {}
  @body = body || ''
  #
  @@log = Logger.new(STDOUT)
  @@log.level = StompServer::LogHelper.get_loglevel()
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/stomp_server_ng/stomp_frame.rb', line 4

def body
  @body
end

#commandObject

Returns the value of attribute command.



4
5
6
# File 'lib/stomp_server_ng/stomp_frame.rb', line 4

def command
  @command
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/stomp_server_ng/stomp_frame.rb', line 4

def headers
  @headers
end

Instance Method Details

#destObject



26
27
28
29
# File 'lib/stomp_server_ng/stomp_frame.rb', line 26

def dest
  #@dest || (@dest = @headers['destination'])
  @headers['destination']
end

#to_sObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/stomp_server_ng/stomp_frame.rb', line 14

def to_s
  result = @command + "\n"
  # 1.8 / 1.9 compat
  @headers['content-length'] = @body.size.to_s if @body.include?(0.chr)
  @headers.each_pair do |key, value|
    result << "#{key}:#{value}\n"
  end
  result << "\n"
  result << @body.to_s
  result << "\000\n"  
end