Class: EventMachine::Protocols::Stomp::Message
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/em/protocols/stomp.rb |
Class Method Summary
- .new ⇒ Message constructor Internal use only Internal use only
Instance Attribute Summary
Instance Method Summary
- #consume_line(line) Internal use only Internal use only
Constructor Details
.new ⇒ Message
This method is for internal use only.
# File 'lib/em/protocols/stomp.rb', line 68
def initialize @header = {} @state = :precommand @content_length = nil end
Instance Attribute Details
#body (rw)
Body of the message
# File 'lib/em/protocols/stomp.rb', line 65
attr_accessor :body
#command (rw)
The command associated with the message, usually 'CONNECTED' or 'MESSAGE'
# File 'lib/em/protocols/stomp.rb', line 60
attr_accessor :command
#header (rw) Also known as: #headers
Hash containing headers such as destination and message-id
# File 'lib/em/protocols/stomp.rb', line 62
attr_accessor :header
#headers (readonly)
Alias for #header.
# File 'lib/em/protocols/stomp.rb', line 63
alias :headers :header
Instance Method Details
#consume_line(line)
This method is for internal use only.
[ GitHub ]
# File 'lib/em/protocols/stomp.rb', line 74
def consume_line line if @state == :precommand unless line =~ /\A\s*\Z/ @command = line @state = :headers end elsif @state == :headers if line == "" if @content_length yield( [:sized_text, @content_length+1] ) else @state = :body yield( [:unsized_text] ) end elsif line =~ /\A([^:]+):(.+)\Z/ k = $1.dup.strip v = $2.dup.strip @header[k] = v if k == "content-length" @content_length = v.to_i end else # This is a protocol error. How to signal it? end elsif @state == :body @body = line yield( [:dispatch] ) end end