Class: AMQ::Protocol::Frame

### Home Classes Methods

### In Files

- lib/amq/protocol/frame.rb

### Parent

Object

### Methods

- ::__new__
- ::decode
- ::decode_header
- ::encode
- ::encode_to_array
- ::encoded_payload
- ::find_type
- ::new
- #final?

### Class/Module Index

Quicksearch

- AMQ
- AMQ::BitSet
- AMQ::Endianness
- AMQ::Hacks
- AMQ::IntAllocator
- AMQ::Pack
- AMQ::Protocol
- AMQ::Protocol::AccessRefused
- AMQ::Protocol::BadResponseError
- AMQ::Protocol::Basic
- AMQ::Protocol::Basic::Ack
- AMQ::Protocol::Basic::Cancel
- AMQ::Protocol::Basic::CancelOk
- AMQ::Protocol::Basic::Consume
- AMQ::Protocol::Basic::ConsumeOk
- AMQ::Protocol::Basic::Deliver
- AMQ::Protocol::Basic::Get
- AMQ::Protocol::Basic::GetEmpty
- AMQ::Protocol::Basic::GetOk
- AMQ::Protocol::Basic::Nack
- AMQ::Protocol::Basic::Publish
- AMQ::Protocol::Basic::Qos
- AMQ::Protocol::Basic::QosOk
- AMQ::Protocol::Basic::Recover
- AMQ::Protocol::Basic::RecoverAsync
- AMQ::Protocol::Basic::RecoverOk
- AMQ::Protocol::Basic::Reject
- AMQ::Protocol::Basic::Return
- AMQ::Protocol::BodyFrame
- AMQ::Protocol::Channel
- AMQ::Protocol::Channel::Close
- AMQ::Protocol::Channel::CloseOk
- AMQ::Protocol::Channel::Flow
- AMQ::Protocol::Channel::FlowOk
- AMQ::Protocol::Channel::Open
- AMQ::Protocol::Channel::OpenOk
- AMQ::Protocol::ChannelError
- AMQ::Protocol::Class
- AMQ::Protocol::CommandInvalid
- AMQ::Protocol::Confirm
- AMQ::Protocol::Confirm::Select
- AMQ::Protocol::Confirm::SelectOk
- AMQ::Protocol::Connection
- AMQ::Protocol::Connection::Blocked
- AMQ::Protocol::Connection::Close
- AMQ::Protocol::Connection::CloseOk
- AMQ::Protocol::Connection::Open
- AMQ::Protocol::Connection::OpenOk
- AMQ::Protocol::Connection::Secure
- AMQ::Protocol::Connection::SecureOk
- AMQ::Protocol::Connection::Start
- AMQ::Protocol::Connection::StartOk
- AMQ::Protocol::Connection::Tune
- AMQ::Protocol::Connection::TuneOk
- AMQ::Protocol::Connection::Unblocked
- AMQ::Protocol::ConnectionForced
- AMQ::Protocol::ContentTooLarge
- AMQ::Protocol::EmptyResponseError
- AMQ::Protocol::Error
- AMQ::Protocol::Exchange
- AMQ::Protocol::Exchange::Bind
- AMQ::Protocol::Exchange::BindOk
- AMQ::Protocol::Exchange::Declare
- AMQ::Protocol::Exchange::DeclareOk
- AMQ::Protocol::Exchange::Delete
- AMQ::Protocol::Exchange::DeleteOk
- AMQ::Protocol::Exchange::Unbind
- AMQ::Protocol::Exchange::UnbindOk
- AMQ::Protocol::Float32Bit
- AMQ::Protocol::Frame
- AMQ::Protocol::FrameError
- AMQ::Protocol::FrameSubclass
- AMQ::Protocol::FrameTypeError
- AMQ::Protocol::HardError
- AMQ::Protocol::HeaderFrame
- AMQ::Protocol::HeartbeatFrame
- AMQ::Protocol::InternalError
- AMQ::Protocol::InvalidPath
- AMQ::Protocol::Method
- AMQ::Protocol::MethodFrame
- AMQ::Protocol::NoConsumers
- AMQ::Protocol::NoRoute
- AMQ::Protocol::NotAllowed
- AMQ::Protocol::NotFound
- AMQ::Protocol::NotImplemented
- AMQ::Protocol::PreconditionFailed
- AMQ::Protocol::Queue
- AMQ::Protocol::Queue::Bind
- AMQ::Protocol::Queue::BindOk
- AMQ::Protocol::Queue::Declare
- AMQ::Protocol::Queue::DeclareOk
- AMQ::Protocol::Queue::Delete
- AMQ::Protocol::Queue::DeleteOk
- AMQ::Protocol::Queue::Purge
- AMQ::Protocol::Queue::PurgeOk
- AMQ::Protocol::Queue::Unbind
- AMQ::Protocol::Queue::UnbindOk
- AMQ::Protocol::ResourceError
- AMQ::Protocol::ResourceLocked
- AMQ::Protocol::SoftError
- AMQ::Protocol::SyntaxError
- AMQ::Protocol::Table
- AMQ::Protocol::Table::InvalidTableError
- AMQ::Protocol::TableValueDecoder
- AMQ::Protocol::TableValueEncoder
- AMQ::Protocol::Tx
- AMQ::Protocol::Tx::Commit
- AMQ::Protocol::Tx::CommitOk
- AMQ::Protocol::Tx::Rollback
- AMQ::Protocol::Tx::RollbackOk
- AMQ::Protocol::Tx::Select
- AMQ::Protocol::Tx::SelectOk
- AMQ::Protocol::TypeConstants
- AMQ::Protocol::UnexpectedFrame
- AMQ::URI

No matching classes.

# AMQ::Protocol::Frame

### Constants

CHANNEL_RANGE
FINAL_OCTET
TYPES
TYPES_OPTIONS
TYPES_REVERSE

### Public Class Methods

__new__(original_type, *args) click to toggle source
Alias for: new
decode(*) click to toggle source

    # File lib/amq/protocol/frame.rb, line 50
    def self.decode(*)
      raise NotImplementedError.new You are supposed to redefine this method, because it's dependent on used IO adapter.This functionality is part of the https://github.com/ruby-amqp/amq-client library.
    end

decode_header(header) click to toggle source

    # File lib/amq/protocol/frame.rb, line 58
    def self.decode_header(header)
      raise EmptyResponseError if header == nil || header.empty?

      type_id, channel, size = header.unpack(PACK_CHAR_UINT16_UINT32)
      type = TYPES_REVERSE[type_id]
      raise FrameTypeError.new(TYPES_OPTIONS) unless type
      [type, channel, size]
    end

encode(type, payload, channel) click to toggle source

    # File lib/amq/protocol/frame.rb, line 30
    def self.encode(type, payload, channel)
      encode_to_array(type, payload, channel).join
    end

encode_to_array(type, payload, channel) click to toggle source

The channel number is 0 for all frames which are global to the connection and 1-65535 for frames that refer to specific channels.

    # File lib/amq/protocol/frame.rb, line 20
    def self.encode_to_array(type, payload, channel)
      raise RuntimeError.new("Channel has to be 0 or an integer in range 1..65535 but was #{channel.inspect}") unless CHANNEL_RANGE.include?(channel)
      raise RuntimeError.new("Payload can't be nil") if payload.nil?
      components = []
      components << [find_type(type), channel, payload.bytesize].pack(PACK_CHAR_UINT16_UINT32)
      components << encoded_payload(payload)
      components << FINAL_OCTET
      components
    end

encoded_payload(payload) click to toggle source

    # File lib/amq/protocol/frame.rb, line 11
    def self.encoded_payload(payload)
      if payload.respond_to?(:force_encoding) && payload.encoding.name != 'BINARY'
        # Only copy if we have to.
        payload = payload.dup.force_encoding('BINARY')
      end
      payload
    end

find_type(type) click to toggle source

    # File lib/amq/protocol/frame.rb, line 44
    def self.find_type(type)
      type_id = if Symbol === type then TYPES[type] else type end
      raise FrameTypeError.new(TYPES_OPTIONS) if type == nil || !TYPES_REVERSE.has_key?(type_id)
      type_id
    end

new(original_type, *args) click to toggle source

    # File lib/amq/protocol/frame.rb, line 38
    def self.new(original_type, *args)
      type_id = find_type(original_type)
      klass = CLASSES[type_id]
      klass.new(*args)
    end

Also aliased as: __new__

### Public Instance Methods

final?() click to toggle source

    # File lib/amq/protocol/frame.rb, line 67
    def final?
      true
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.