Class: EventMachine::Protocols::Stomp::Message
- Inherits:
-
Object
- Object
- EventMachine::Protocols::Stomp::Message
- Defined in:
- lib/protocols/stomp.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#command ⇒ Object
Returns the value of attribute command.
-
#header ⇒ Object
Returns the value of attribute header.
Instance Method Summary collapse
- #consume_line(line) ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
62 63 64 65 66 |
# File 'lib/protocols/stomp.rb', line 62 def initialize @header = {} @state = :precommand @content_length = nil end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
61 62 63 |
# File 'lib/protocols/stomp.rb', line 61 def body @body end |
#command ⇒ Object
Returns the value of attribute command.
61 62 63 |
# File 'lib/protocols/stomp.rb', line 61 def command @command end |
#header ⇒ Object
Returns the value of attribute header.
61 62 63 |
# File 'lib/protocols/stomp.rb', line 61 def header @header end |
Instance Method Details
#consume_line(line) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/protocols/stomp.rb', line 67 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 |