Class: Qpid::Proton::Session

Inherits:
Endpoint show all
Includes:
Util::SwigHelper, 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 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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::SwigHelper

included

Methods included from Util::Wrapper

#impl, #impl=, included, registry

Methods inherited from Endpoint

#_update_condition, #check_state, #handler, #handler=, #local_active?, #local_closed?, #local_uninit?, #remote_active?, #remote_closed?, #remote_condition, #remote_uninit?, #transport

Methods included from Util::Engine

#condition_to_object, #data_to_object, #object_to_condition, #object_to_data, receive_message

Constructor Details

#initialize(impl) ⇒ Session

Returns a new instance of Session.



85
86
87
88
# File 'lib/core/session.rb', line 85

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

Instance Attribute Details

#incoming_bytesFixnum (readonly)

Returns The number of incomign bytes currently being buffered.

Returns:

  • (Fixnum)

    The number of incomign bytes currently being buffered.



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

proton_caller :incoming_bytes

#incoming_capacityFixnum

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:

  • (Fixnum)

    The incoing capacity of the session, measured in bytes.



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

proton_accessor :incoming_capacity

#outgoing_bytesFixnum (readonly)

Returns The number of outgoing bytes currently being buffered.

Returns:

  • (Fixnum)

    The number of outgoing bytes currently being buffered.



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

proton_caller :outgoing_bytes

#stateFixnum (readonly)

Returns The endpoint state.

Returns:

  • (Fixnum)

    The endpoint state.



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

proton_caller :state

Class Method Details

.wrap(impl) ⇒ Object



79
80
81
82
# File 'lib/core/session.rb', line 79

def self.wrap(impl)
  return nil if impl.nil?
  self.fetch_instance(impl, :pn_session_attachments) || Session.new(impl)
end

Instance Method Details

#_local_conditionObject



152
153
154
# File 'lib/core/session.rb', line 152

def _local_condition
  Cproton.pn_session_condition(@impl)
end

#_remote_conditionObject



157
158
159
# File 'lib/core/session.rb', line 157

def _remote_condition # :nodoc:
  Cproton.pn_session_remote_condition(@impl)
end

#closeObject

Closed the session.

Once this operation has completed, the state flag will be set. This may be called without calling #open, in which case it is the equivalence of calling #open and then close immediately.



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

def close
  self._update_condition
  Cproton.pn_session_close(@impl)
end

#connectionConnection

Returns the parent connection.

Returns:



119
120
121
# File 'lib/core/session.rb', line 119

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

#next(state_mask) ⇒ Session?

Retrieves the next session from a given connection that matches the specified state mask.

When uses with Connection#session_head an application can access all of the session son the connection that match the given state.

Parameters:

  • state_mask (Fixnum)

    The state mask to match.

Returns:

  • (Session, nil)

    The next session if one matches, or nil.



111
112
113
# File 'lib/core/session.rb', line 111

def next(state_mask)
  Session.wrap(Cproton.pn_session_next(@impl, state_mask))
end

#openObject

Opens the session.

Once this operaton has completed, the state flag is updated.



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

proton_caller :open

#receiver(name) ⇒ Receiver?

Constructs a new receiver.

Each receiver between two AMQP containers must be uniquely named. Note that this uniqueness cannot be enforced at the library level, so some consideration should be taken in choosing link names.

Parameters:

  • name (String)

    The link name.

Returns:

  • (Receiver, nil)

    The receiver, or nil if an error occurred.



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

def receiver(name)
  Receiver.new(Cproton.pn_receiver(@impl, name))
end

#sender(name) ⇒ Sender?

Constructs a new sender.

Each sender between two AMQP containers must be uniquely named. Note that this uniqueness cannot be enforced at the library level, so some consideration should be taken in choosing link names.

Parameters:

  • name (String)

    The link name.

Returns:

  • (Sender, nil)

    The sender, or nil if an error occurred.



133
134
135
# File 'lib/core/session.rb', line 133

def sender(name)
  Sender.new(Cproton.pn_sender(@impl, name))
end