Class: Qpid::Proton::Session

Inherits:
Endpoint show all
Includes:
Util::Deprecation, Util::Wrapper
Defined in:
lib/core/session.rb

Overview

A session is the parent for senders and receivers.

A Session has a single parent Qpid::Proton::Connection instance.

Constant Summary collapse

PROTON_METHOD_PREFIX =
"pn_session"

Constants included from Util::Deprecation

Util::Deprecation::DEPRECATE_FULL_TRACE, Util::Deprecation::MATCH_DIR

Constants inherited from Endpoint

Endpoint::LOCAL_ACTIVE, Endpoint::LOCAL_CLOSED, Endpoint::LOCAL_MASK, Endpoint::LOCAL_UNINIT, Endpoint::REMOTE_ACTIVE, Endpoint::REMOTE_CLOSED, Endpoint::REMOTE_MASK, Endpoint::REMOTE_UNINIT

Instance Attribute Summary collapse

Attributes included from Util::Wrapper

#impl

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Wrapper

included, #inspect, registry, #to_s

Methods included from Util::Deprecation

deprecated, #deprecated, included

Methods inherited from Endpoint

#check_state, #closed?, #condition, #local_closed?, #local_condition, #local_open?, #local_uninit?, #open?, #remote_closed?, #remote_condition, #remote_open?, #remote_uninit?, #transport

Constructor Details

#initialize(impl) ⇒ Session

Returns a new instance of Session.



75
76
77
78
# File 'lib/core/session.rb', line 75

def initialize(impl)
  @impl = impl
  self.class.store_instance(self, :pn_session_attachments)
end

Instance Attribute Details

#incoming_bytesInteger (readonly)

Returns The number of incomign bytes currently being buffered.

Returns:

  • (Integer)

    The number of incomign bytes currently being buffered.



57
# File 'lib/core/session.rb', line 57

proton_caller :incoming_bytes

#incoming_capacityInteger

The incoming capacity of a session determines how much incoming message data the session will buffer. Note that if this value is less than the negotatied frame size of the transport, it will be rounded up to one full frame.

Returns:

  • (Integer)

    The incoing capacity of the session, measured in bytes.



42
# File 'lib/core/session.rb', line 42

proton_set_get :incoming_capacity

#outgoing_bytesInteger (readonly)

Returns The number of outgoing bytes currently being buffered.

Returns:

  • (Integer)

    The number of outgoing bytes currently being buffered.



51
# File 'lib/core/session.rb', line 51

proton_caller :outgoing_bytes

#stateInteger (readonly)

Returns The endpoint state.

Returns:

  • (Integer)

    The endpoint state.



66
# File 'lib/core/session.rb', line 66

proton_caller :state

Class Method Details

.wrap(impl) ⇒ Object



69
70
71
72
# 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

Instance Method Details

#close(error = nil) ⇒ Object

Close the local end of the session. The remote end may or may not be closed.

Parameters:

  • error (Condition) (defaults to: nil)

    Optional error condition to send with the close.



82
83
84
85
# File 'lib/core/session.rb', line 82

def close(error=nil)
  Condition.assign(_local_condition, error)
  Cproton.pn_session_close(@impl)
end

#connectionConnection

Returns the parent connection.

Returns:



97
98
99
# File 'lib/core/session.rb', line 97

def connection
  Connection.wrap(Cproton.pn_session_connection(@impl))
end

Get the links on this Session.

Overloads:

  • #each_link {|l| ... } ⇒ Object

    Yield Parameters:

    • l (Link)

      pass each link to block

  • #each_linkEnumerator

    Returns enumerator over links.

    Returns:

    • (Enumerator)

      enumerator over links



134
135
136
137
138
139
140
141
142
143
# File 'lib/core/session.rb', line 134

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

#each_receiverObject

Get the Receiver links - see #each_link



149
# File 'lib/core/session.rb', line 149

def each_receiver() each_link.select { |l| l.receiver? }; end

#each_senderObject

Get the Qpid::Proton::Sender links - see #each_link



146
# File 'lib/core/session.rb', line 146

def each_sender() each_link.select { |l| l.sender? }; end

#next(state_mask) ⇒ Object

Deprecated.


88
89
90
91
# 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

#open_receiver(opts = nil) ⇒ Receiver

Create and open a Receiver link, see Receiver#open

Parameters:

Returns:



116
117
118
119
# File 'lib/core/session.rb', line 116

def open_receiver(opts=nil) 
  name = opts[:name] rescue connection.link_name
  Receiver.new(Cproton.pn_receiver(@impl, name)).open(opts)
end

#open_sender(opts = nil) ⇒ Sender

Create and open a Qpid::Proton::Sender link, see #open

Parameters:

Returns:



124
125
126
127
# File 'lib/core/session.rb', line 124

def open_sender(opts=nil)
  name = opts[:name] rescue connection.link_name
  Sender.new(Cproton.pn_sender(@impl, name)).open(opts)
end

#receiver(name) ⇒ Object

Deprecated.


108
109
110
111
# File 'lib/core/session.rb', line 108

def receiver(name)
  deprecated __method__, "open_receiver"
  Receiver.new(Cproton.pn_receiver(@impl, name))
end

#sender(name) ⇒ Object

Deprecated.


102
103
104
105
# File 'lib/core/session.rb', line 102

def sender(name)
  deprecated __method__, "open_sender"
  Sender.new(Cproton.pn_sender(@impl, name));
end