lib/onstomp/client.rb in onstomp-1.0.0pre1 vs lib/onstomp/client.rb in onstomp-1.0.0

- old
+ new

@@ -48,11 +48,11 @@ attr_configurable_processor :processor # Creates a new client for the specified uri and optional hash of options. # @param [String,URI] uri # @param [{Symbol => Object}] options - def initialize(uri, options={}) + def initialize uri, options={} @uri = uri.is_a?(::URI) ? uri : ::URI.parse(uri) @ssl = options.delete(:ssl) configure_configurable options configure_subscription_management configure_receipt_management @@ -63,11 +63,11 @@ # Connects to the STOMP broker referenced by {#uri}. Includes optional # headers in the CONNECT frame, if specified. # @param [{#to_sym => #to_s}] headers # @return [self] - def connect(headers={}) + def connect headers={} @connection = OnStomp::Connections.connect self, headers, { :'accept-version' => @versions.join(','), :host => @host, :'heart-beat' => @heartbeats.join(','), :login => @login, :passcode => @passcode }, pending_connection_events processor_inst.start @@ -78,11 +78,12 @@ # Sends a DISCONNECT frame to the broker and blocks until the connection # has been closed. This method ensures that all frames not yet sent to # the broker will get processed barring any IO exceptions. # @param [{#to_sym => #to_s}] headers # @return [OnStomp::Components::Frame] transmitted DISCONNECT frame - def disconnect_with_flush(headers={}) + def disconnect_with_flush headers={} + processor_inst.prepare_to_close disconnect_without_flush(headers).tap do processor_inst.join end end alias :disconnect_without_flush :disconnect @@ -109,14 +110,14 @@ # Ultimately sends a {OnStomp::Components::Frame frame} to the STOMP broker. # This method should not be invoked directly. Use the frame methods provided # by the {OnStomp::Interfaces:FrameMethod} interface. # @return [OnStomp::Components::Frame] - def transmit(frame, cbs={}) + def transmit frame, cbs={} frame.tap do register_callbacks frame, cbs trigger_before_transmitting frame - connection.write_frame_nonblock frame + connection && connection.write_frame_nonblock(frame) end end # Called by {#connection} when a frame has been read from the socket # connection to the STOMP broker.