Class: StompServer::StompFrame
- Inherits:
-
Object
- Object
- StompServer::StompFrame
- Defined in:
- lib/stomp_server_ng/stomp_frame.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#command ⇒ Object
Returns the value of attribute command.
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
- #dest ⇒ Object
-
#initialize(command = nil, headers = nil, body = nil) ⇒ StompFrame
constructor
A new instance of StompFrame.
- #to_s ⇒ Object
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
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/stomp_server_ng/stomp_frame.rb', line 4 def body @body end |
#command ⇒ Object
Returns the value of attribute command.
4 5 6 |
# File 'lib/stomp_server_ng/stomp_frame.rb', line 4 def command @command end |
#headers ⇒ Object
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
#dest ⇒ Object
26 27 28 29 |
# File 'lib/stomp_server_ng/stomp_frame.rb', line 26 def dest #@dest || (@dest = @headers['destination']) @headers['destination'] end |
#to_s ⇒ Object
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 |