Class: Rex::Proto::Amqp::Version091::Client::Channel
- Inherits:
-
Object
- Object
- Rex::Proto::Amqp::Version091::Client::Channel
- Includes:
- Rex::Proto::Amqp::Version091
- Defined in:
- lib/rex/proto/amqp/version_0_9_1/client/channel.rb
Instance Attribute Summary collapse
-
#client ⇒ Client
readonly
The underlying AMQP client to which this channel belongs.
-
#id ⇒ Integer
readonly
The channel ID.
Instance Method Summary collapse
-
#basic_publish(exchange: '', routing_key: '', message: '', properties: {}) ⇒ NilClass
Publish a message on the channel.
- #close ⇒ Object
-
#initialize(client, id) ⇒ Channel
constructor
A new instance of Channel.
Constructor Details
#initialize(client, id) ⇒ Channel
Returns a new instance of Channel.
13 14 15 16 |
# File 'lib/rex/proto/amqp/version_0_9_1/client/channel.rb', line 13 def initialize(client, id) @client = client @id = id end |
Instance Attribute Details
#client ⇒ Client (readonly)
Returns The underlying AMQP client to which this channel belongs.
9 10 11 |
# File 'lib/rex/proto/amqp/version_0_9_1/client/channel.rb', line 9 def client @client end |
#id ⇒ Integer (readonly)
Returns The channel ID.
12 13 14 |
# File 'lib/rex/proto/amqp/version_0_9_1/client/channel.rb', line 12 def id @id end |
Instance Method Details
#basic_publish(exchange: '', routing_key: '', message: '', properties: {}) ⇒ NilClass
Publish a message on the channel.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rex/proto/amqp/version_0_9_1/client/channel.rb', line 39 def basic_publish(exchange: '', routing_key: '', message: '', properties: {}) ba_publish = Rex::Proto::Amqp::Version091::Frames::AmqpVersion091MethodFrame.new ba_publish.header.frame_channel = @id ba_publish.arguments = Rex::Proto::Amqp::Version091::Frames::MethodArguments::AmqpVersion091BasicPublish.new ba_publish.arguments.exchange = exchange ba_publish.arguments.routing_key = routing_key @client.send_frame(ba_publish) co_header = Rex::Proto::Amqp::Version091::Frames::AmqpVersion091ContentHeaderFrame.new co_header.header.frame_channel = @id co_header.body_size = .size co_header.flags.snapshot.keys.each do |property| next unless properties[property] co_header.flags.send(property).assign(true) co_header.send(property).assign(properties[property]) end @client.send_frame(co_header) co_body = Rex::Proto::Amqp::Version091::Frames::AmqpVersion091ContentBodyFrame.new co_body.header.frame_channel = @id co_body.payload = @client.send_frame(co_body) nil end |
#close ⇒ Object
66 67 68 |
# File 'lib/rex/proto/amqp/version_0_9_1/client/channel.rb', line 66 def close @client.channel_close(self) end |