class Qpid::Proton::Session
A session is the parent for senders and receivers.
A Session
has a single parent Qpid::Proton::Connection
instance.
Constants
- PROTON_METHOD_PREFIX
@private
Public Class Methods
@private
# File lib/core/session.rb, line 75 def initialize(impl) @impl = impl self.class.store_instance(self, :pn_session_attachments) end
@private
# File lib/core/session.rb, line 69 def self.wrap(impl) return nil if impl.nil? self.fetch_instance(impl, :pn_session_attachments) || Session.new(impl) end
Public Instance Methods
Close the local end of the session. The remote end may or may not be closed. @param error [Condition] Optional error condition to send with the close.
# File lib/core/session.rb, line 82 def close(error=nil) Condition.assign(_local_condition, error) Cproton.pn_session_close(@impl) end
Returns the parent connection.
@return [Connection] The connection.
# File lib/core/session.rb, line 97 def connection Connection.wrap(Cproton.pn_session_connection(@impl)) end
Get the links on this Session
. @overload each_link
@yieldparam l [Link] pass each link to block
@overload each_link
@return [Enumerator] enumerator over links
# File lib/core/session.rb, line 132 def each_link return enum_for(:each_link) unless block_given? l = Cproton.pn_link_head(Cproton.pn_session_connection(@impl), 0); while l link = Link.wrap(l) yield link if link.session == self l = Cproton.pn_link_next(l, 0) end self end
Get the {Receiver} links - see {#each_link}
# File lib/core/session.rb, line 147 def each_receiver() each_link.select { |l| l.receiver? }; end
Get the {Sender} links - see {#each_link}
# File lib/core/session.rb, line 144 def each_sender() each_link.select { |l| l.sender? }; end
@deprecated use {Connection#each_session}
# File lib/core/session.rb, line 88 def next(state_mask) deprecated __method__, "Connection#each_session" Session.wrap(Cproton.pn_session_next(@impl, state_mask)) end
Create and open a {Receiver} link, see {Receiver#open} @param opts [Hash] receiver options, see {Receiver#open} @return [Receiver]
# File lib/core/session.rb, line 116 def open_receiver(opts=nil) Receiver.new(Cproton.pn_receiver(@impl, link_name(opts))).open(opts) end
Create and open a {Sender} link, see {#open} @param opts [Hash] sender options, see {Sender#open} @return [Sender]
# File lib/core/session.rb, line 123 def open_sender(opts=nil) Sender.new(Cproton.pn_sender(@impl, link_name(opts))).open(opts) end
@deprecated use {#open_receiver}
# File lib/core/session.rb, line 108 def receiver(name) deprecated __method__, "open_receiver" Receiver.new(Cproton.pn_receiver(@impl, name)) end
@deprecated use {#open_sender}
# File lib/core/session.rb, line 102 def sender(name) deprecated __method__, "open_sender" Sender.new(Cproton.pn_sender(@impl, name)); end
Private Instance Methods
# File lib/core/session.rb, line 155 def _local_condition Cproton.pn_session_condition(@impl) end
# File lib/core/session.rb, line 151 def link_name(opts) (opts.respond_to?(:to_hash) && opts[:name]) || connection.link_name end