Included Modules

EventMachine::Protocols::Stomp

Implements Stomp (docs.codehaus.org/display/STOMP/Protocol).

Usage example

 module StompClient
   include EM::Protocols::Stomp

   def connection_completed
     connect :login => 'guest', :passcode => 'guest'
   end

   def receive_msg msg
     if msg.command == "CONNECTED"
       subscribe '/some/topic'
     else
       p ['got a message', msg]
       puts msg.body
     end
   end
 end

 EM.run{
   EM.connect 'localhost', 61613, StompClient
 }

Public Instance Methods

ack(msgid) click to toggle source

ACK command, for acknowledging receipt of messages

 module StompClient
   include EM::P::Stomp

   def connection_completed
     connect :login => 'guest', :passcode => 'guest'
     # subscribe with ack mode
     subscribe '/some/topic', true
   end

   def receive_msg msg
     if msg.command == "MESSAGE"
       ack msg.headers['message-id']
       puts msg.body
     end
   end
 end
     # File lib/em/protocols/stomp.rb, line 193
193:       def ack msgid
194:         send_frame "ACK", 'message-id'=> msgid
195:       end
connect(parms={}) click to toggle source

CONNECT command, for authentication

 connect :login => 'guest', :passcode => 'guest'
     # File lib/em/protocols/stomp.rb, line 154
154:       def connect parms={}
155:         send_frame "CONNECT", parms
156:       end
receive_msg(msg) click to toggle source

Invoked with an incoming Stomp::Message received from the STOMP server

     # File lib/em/protocols/stomp.rb, line 146
146:       def receive_msg msg
147:         # stub, overwrite this in your handler
148:       end
send(destination, body, parms={}) click to toggle source

SEND command, for publishing messages to a topic

 send '/topic/name', 'some message here'
     # File lib/em/protocols/stomp.rb, line 162
162:       def send destination, body, parms={}
163:         send_frame "SEND", parms.merge( :destination=>destination ), body.to_s
164:       end
subscribe(dest, ack=false) click to toggle source

SUBSCRIBE command, for subscribing to topics

 subscribe '/topic/name', false
     # File lib/em/protocols/stomp.rb, line 170
170:       def subscribe dest, ack=false
171:         send_frame "SUBSCRIBE", {:destination=>dest, :ack=>(ack ? "client" : "auto")}
172:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.