class Qpid::Proton::Transport

@deprecated all important features are available from {#Connection}

Constants

PROTON_METHOD_PREFIX

@private

TRACE_DRV

Log driver related events; i.e., initialization, end of stream, etc.

TRACE_FRM

Log frames into/out of the transport.

TRACE_OFF

Turn logging off entirely.

TRACE_RAW

Log raw binary data into/out of the transport.

Public Class Methods

new(impl = Cproton.pn_transport) click to toggle source

Creates a new transport instance.

# File lib/core/transport.rb, line 171
def initialize(impl = Cproton.pn_transport)
  @impl = impl
  @ssl = nil
  self.class.store_instance(self, :pn_transport_attachments)
end
wrap(impl) click to toggle source

@private

# File lib/core/transport.rb, line 164
def self.wrap(impl)
  return nil if impl.nil?

  self.fetch_instance(impl, :pn_transport_attachments) || Transport.new(impl)
end

Public Instance Methods

apply(opts) click to toggle source

@private Options are documented {Connection#open}, keep that consistent with this

# File lib/core/transport.rb, line 358
def apply opts
  sasl if opts[:sasl_enabled]                                 # Explicitly enabled
  unless opts.include?(:sasl_enabled) && !opts[:sasl_enabled] # Not explicitly disabled
    sasl.allowed_mechs = opts[:sasl_allowed_mechs] if opts.include? :sasl_allowed_mechs
    sasl.allow_insecure_mechs = opts[:sasl_allow_insecure_mechs] if opts.include? :sasl_allow_insecure_mechs
  end
  self.channel_max= opts[:max_sessions] if opts.include? :max_sessions
  self.max_frame = opts[:max_frame_size] if opts.include? :max_frame_size
  # NOTE: The idle_timeout option is in Numeric *seconds*, can be Integer, Float or Rational.
  # This is consistent with idiomatic ruby.
  # The transport #idle_timeout property is in *milliseconds* passed direct to C.
  # Direct use of the transport is deprecated.
  self.idle_timeout= (opts[:idle_timeout]*1000).round if opts.include? :idle_timeout
  self.ssl(opts[:ssl_domain]) if opts[:ssl_domain]
end
bind(connection) click to toggle source

Binds to the given connection.

@param connection [Connection] The connection.

# File lib/core/transport.rb, line 204
def bind(connection)
  Cproton.pn_transport_bind(@impl, connection.impl)
end
close_head() click to toggle source

Indicate that the output has closed.

Tells the transport that no more output will be popped.

@raise [TransportError] If an error occurs.

# File lib/core/transport.rb, line 311
def close_head
  Cproton.pn_transport_close_head(@impl)
end
close_tail() click to toggle source

Indicate that the input has reached EOS (end of stream).

This tells the transport that no more input will be forthcoming.

@raise [TransportError] If an error occurs.

# File lib/core/transport.rb, line 277
def close_tail
  Cproton.pn_transport_close_tail(@impl)
end
condition() click to toggle source

@return [Condition, nil] transport error condition or nil if there is no error.

# File lib/core/transport.rb, line 190
def condition
  Condition.convert(Cproton.pn_transport_condition(@impl))
end
condition=(c) click to toggle source

Set the error condition for the transport. @param c [Condition] The condition to set

# File lib/core/transport.rb, line 196
def condition=(c)
  Condition.assign(Cproton.pn_transport_condition(@impl), c)
end
connection() click to toggle source

Return the AMQP connection associated with the transport.

@return [Connection, nil] The bound connection, or nil.

# File lib/core/transport.rb, line 231
def connection
  Connection.wrap(Cproton.pn_transport_connection(@impl))
end
log(message) click to toggle source

Log a message to the transport's logging mechanism.

This can be using in a debugging scenario as the message will be prepended with the transport's identifier.

@param message [String] The message to be logged.

# File lib/core/transport.rb, line 242
def log(message)
  Cproton.pn_transport_log(@impl, message)
end
peek(size) click to toggle source

Returns the specified number of bytes from the transport's buffers.

@param size [Integer] The number of bytes to return.

@return [String] The data peeked.

@raise [TransportError] If an error occurs.

# File lib/core/transport.rb, line 289
def peek(size)
  cd, out = Cproton.pn_transport_peek(@impl, size)
  return nil if cd == Qpid::Proton::Error::EOS
  raise TransportError.new if cd < -1
  out
end
pop(size) click to toggle source

Removes the specified number of bytes from the pending output queue following the transport's head pointer.

@param size [Integer] The number of bytes to remove.

# File lib/core/transport.rb, line 301
def pop(size)
  Cproton.pn_transport_pop(@impl, size)
end
process(size) click to toggle source

Process input data following the tail pointer.

Calling this function will cause the transport to consume the specified number of bytes of input occupying the free space following the tail pointer. It may also change the value for tail, as well as the amount of free space reported by capacity.

@param size [Integer] The number of bytes to process.

@raise [TransportError] If an error occurs.

# File lib/core/transport.rb, line 267
def process(size)
  Cproton.pn_transport_process(@impl, size)
end
push(data) click to toggle source

Pushes the supplied bytes into the tail of the transport.

@param data [String] The bytes to be pushed.

@return [Integer] The number of bytes pushed.

# File lib/core/transport.rb, line 252
def push(data)
  Cproton.pn_transport_push(@impl, data, data.length)
end
quiesced?() click to toggle source

Returns whether the transport has any buffered data.

@return [Boolean] True if the transport has no buffered data.

# File lib/core/transport.rb, line 185
def quiesced?
  Cproton.pn_transport_quiesced(@impl)
end
sasl() click to toggle source

Create, or return existing, SSL object for the transport. @return [SASL] the SASL object

# File lib/core/transport.rb, line 336
def sasl
  SASL.new(self)
end
set_server() click to toggle source

Set server mode for this tranport - enables protocol detection and server-side authentication for incoming connections

# File lib/core/transport.rb, line 179
def set_server() Cproton.pn_transport_set_server(@impl); end
ssl(domain = nil, session_details = nil) click to toggle source

Creates, or returns an existing, SSL object for the transport.

@param domain [SSLDomain] The SSL domain. @param session_details [SSLDetails] The SSL session details.

@return [SSL] The SSL object.

# File lib/core/transport.rb, line 347
def ssl(domain = nil, session_details = nil)
  @ssl ||= SSL.create(self, domain, session_details)
end
ssl?() click to toggle source

@private

# File lib/core/transport.rb, line 352
def ssl?
  !@ssl.nil?
end
tick(now) click to toggle source

Process any pending transport timer events.

This method should be called after all pending input has been processed by the transport (see input), and before generating output (see output).

It returns the deadline for the next pending timer event, if any art present.

@param now [Time] The timestamp.

@return [Integer] If non-zero, the expiration time of the next pending

timer event for the transport. The caller must invoke #tick again at
least once at or before this deadline occurs.
# File lib/core/transport.rb, line 330
def tick(now)
  Cproton.pn_transport_tick(@impl, now)
end
trace(level) click to toggle source

Updates the transports trace flags.

@param level [Integer] The trace level.

@see TRACE_OFF @see TRACE_RAW @see TRACE_FRM @see TRACE_DRV

# File lib/core/transport.rb, line 223
def trace(level)
  Cproton.pn_transport_trace(@impl, level)
end
unbind() click to toggle source

Unbinds from the previous connection.

# File lib/core/transport.rb, line 210
def unbind
  Cproton.pn_transport_unbind(@impl)
end