Class: StompDroid::Server
- Inherits:
-
Object
- Object
- StompDroid::Server
- Includes:
- Celluloid::IO
- Defined in:
- lib/stomp_droid/server.rb
Instance Attribute Summary collapse
-
#message_body ⇒ Object
Returns the value of attribute message_body.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
-
#sent_message_dir ⇒ Object
Returns the value of attribute sent_message_dir.
Class Method Summary collapse
Instance Method Summary collapse
- #finalize ⇒ Object
- #handle_connection(socket) ⇒ Object
-
#initialize(host, port, options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(host, port, options = {}) ⇒ Server
Returns a new instance of Server.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/stomp_droid/server.rb', line 9 def initialize(host, port, = {}) @host = host @port = port @message_body = [:message] @queue_name = [:queue_name] @sent_message_dir = [:sent_message_dir] @server = TCPServer.new(@host, @port) async.run end |
Instance Attribute Details
#message_body ⇒ Object
Returns the value of attribute message_body.
5 6 7 |
# File 'lib/stomp_droid/server.rb', line 5 def @message_body end |
#queue_name ⇒ Object
Returns the value of attribute queue_name.
6 7 8 |
# File 'lib/stomp_droid/server.rb', line 6 def queue_name @queue_name end |
#sent_message_dir ⇒ Object
Returns the value of attribute sent_message_dir.
7 8 9 |
# File 'lib/stomp_droid/server.rb', line 7 def @sent_message_dir end |
Class Method Details
.start(*opts) ⇒ Object
22 23 24 |
# File 'lib/stomp_droid/server.rb', line 22 def self.start(*opts) supervise(*opts) end |
Instance Method Details
#finalize ⇒ Object
34 35 36 |
# File 'lib/stomp_droid/server.rb', line 34 def finalize @server.close if @server end |
#handle_connection(socket) ⇒ Object
30 31 32 |
# File 'lib/stomp_droid/server.rb', line 30 def handle_connection(socket) Connection.new(self, socket).handle end |
#run ⇒ Object
26 27 28 |
# File 'lib/stomp_droid/server.rb', line 26 def run loop { async.handle_connection @server.accept } end |