class Qpid::Proton::Link

The base for both Sender and Receiver, providing common functionality between both ends.

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

Constants

PROTON_METHOD_PREFIX

@private

RCV_FIRST

The receiver will settle deliveries regardless of what the sender does.

RCV_SECOND

The receiver will only settle deliveries after the sender settles.

SND_MIXED

The sender may send a mixture of settled and unsettled deliveries.

SND_SETTLED

The sender will send all deliveries settled to the receiver.

SND_UNSETTLED

The sender will send all deliveries initially unsettled.

Public Class Methods

new(impl) click to toggle source

@private

# File lib/core/link.rb, line 207
def initialize(impl)
  @impl = impl
  self.class.store_instance(self, :pn_link_attachments)
end
wrap(impl) click to toggle source

@private

# File lib/core/link.rb, line 200
def self.wrap(impl)
  return unless impl
  return fetch_instance(impl, :pn_link_attachments) ||
    (Cproton.pn_link_is_sender(impl) ? Sender : Receiver).new(impl)
end

Public Instance Methods

==(other) click to toggle source
# File lib/core/link.rb, line 355
def ==(other)
  other.respond_to?(:impl) &&
  (Cproton.pni_address_of(other.impl) == Cproton.pni_address_of(@impl))
end
_local_condition() click to toggle source

@private

# File lib/core/link.rb, line 346
def _local_condition
  Cproton.pn_link_condition(@impl)
end
_remote_condition() click to toggle source

@private

# File lib/core/link.rb, line 351
def _remote_condition
  Cproton.pn_link_remote_condition(@impl)
end
close(error=nil) click to toggle source

Close the local end of the link. The remote end may or may not be closed. @param error [Condition] Optional error condition to send with the close.

# File lib/core/link.rb, line 56
def close(error=nil)
  Condition.assign(_local_condition, error)
  Cproton.pn_link_close(@impl)
end
connection() click to toggle source

Returns the parent connection.

@return [Connection] The connection.

# File lib/core/link.rb, line 273
def connection
  self.session.connection
end
current() click to toggle source

Returns the current delivery.

Each link maintains a sequence of deliveries in the order they were created, along with a reference to the current delivery. All send and receive operations on a link take place on the current delivery. If a link has no current delivery, the current delivery is automatically pointed to the next delivery created on the link.

Once initialized, the current delivery remains the same until it is changed by advancing, or until it is settled.

@see next @see Delivery#settle

@return [Delivery] The current delivery.

# File lib/core/link.rb, line 300
def current
  Delivery.wrap(Cproton.pn_link_current(@impl))
end
delivery(tag) click to toggle source

@deprecated use {Sender#send}

# File lib/core/link.rb, line 279
def delivery(tag)
  deprecated __method__, "Sender#send"
  Delivery.new(Cproton.pn_delivery(@impl, tag))
end
error() click to toggle source

Returns additional error information.

Whenever a link operation fails (i.e., returns an error code) additional error details can be obtained from this method. Ther error object that is returned may also be used to clear the error condition.

@return [Error] The error.

# File lib/core/link.rb, line 220
def error
  Cproton.pn_link_error(@impl)
end
next(state_mask) click to toggle source

@deprecated use {Session#each_link, Connection#each_link}

# File lib/core/link.rb, line 225
def next(state_mask)
  deprecated __method__, "Session#each_link, Connection#each_link"
  return Link.wrap(Cproton.pn_link_next(@impl, state_mask))
end
rcv_settle_mode() click to toggle source

Returns the local receiver settle mode.

@return [Integer] The local receiver settle mode.

# File lib/core/link.rb, line 341
def rcv_settle_mode
  Cproton.pn_link_rcv_settle_mode(@impl)
end
rcv_settle_mode=(mode) click to toggle source

Sets the local receiver settle mode.

@param mode [Integer] The settle mode.

@see #RCV_FIRST @see #RCV_SECOND

# File lib/core/link.rb, line 333
def rcv_settle_mode=(mode)
  Cproton.pn_link_set_rcv_settle_mode(@impl, mode)
end
remote_source() click to toggle source

Returns a representation of the remotely defined source terminus.

@return [Terminus] The terminus.

# File lib/core/link.rb, line 249
def remote_source
  Terminus.new(Cproton.pn_link_remote_source(@impl))
end
remote_target() click to toggle source

Returns a representation of the remotely defined target terminus.

@return [Terminus] The terminus.

# File lib/core/link.rb, line 257
def remote_target
  Terminus.new(Cproton.pn_link_remote_target(@impl))
end
session() click to toggle source

Returns the parent session.

@return [Session] The session.

# File lib/core/link.rb, line 265
def session
  Session.wrap(Cproton.pn_link_session(@impl))
end
snd_settle_mode() click to toggle source

Returns the local sender settle mode.

@return [Integer] The local sender settle mode.

@see snd_settle_mode

# File lib/core/link.rb, line 322
def snd_settle_mode
  Cproton.pn_link_snd_settle_mode(@impl)
end
snd_settle_mode=(mode) click to toggle source

Sets the local sender settle mode.

@param mode [Integer] The settle mode.

@see #SND_UNSETTLED @see #SND_SETTLED @see #SND_MIXED

# File lib/core/link.rb, line 312
def snd_settle_mode=(mode)
  Cproton.pn_link_set_snd_settle_mode(@impl, mode)
end
source() click to toggle source

Returns the locally defined source terminus.

@return [Terminus] The terminus

# File lib/core/link.rb, line 233
def source
  Terminus.new(Cproton.pn_link_source(@impl))
end
target() click to toggle source

Returns the locally defined target terminus.

@return [Terminus] The terminus.

# File lib/core/link.rb, line 241
def target
  Terminus.new(Cproton.pn_link_target(@impl))
end