Class: DRbDump::Message
- Inherits:
-
Object
- Object
- DRbDump::Message
- Defined in:
- lib/drbdump/message.rb
Overview
Contains common parts of MessageSend and MessageResult
Direct Known Subclasses
Class Method Summary collapse
-
.from_stream(drbdump, packet, stream) ⇒ Object
Creates the appropriate message instance from the next
packetwhich was captured bydrbdumpon the givenstream.
Instance Method Summary collapse
-
#destination ⇒ Object
The resolved destination for the message.
-
#initialize(drbdump, packet) ⇒ Message
constructor
Initializes a message from
packetcaptured by adrbdump. -
#resolve_addresses ⇒ Object
Resolves source and destination addresses.
-
#source ⇒ Object
The resolved source of the message.
Constructor Details
#initialize(drbdump, packet) ⇒ Message
Initializes a message from packet captured by a drbdump
26 27 28 29 30 31 32 33 34 |
# File 'lib/drbdump/message.rb', line 26 def initialize drbdump, packet @drbdump = drbdump @loader = drbdump.loader @packet = packet @statistics = drbdump.statistics @source = nil @destination = nil end |
Class Method Details
.from_stream(drbdump, packet, stream) ⇒ Object
Creates the appropriate message instance from the next packet which was captured by drbdump on the given stream.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/drbdump/message.rb', line 10 def self.from_stream drbdump, packet, stream loader = drbdump.loader first_chunk = loader.load stream case first_chunk.load when nil, Integer then DRbDump::MessageSend.new drbdump, packet, first_chunk, stream when true, false then DRbDump::MessageResult.new drbdump, packet, first_chunk, stream end end |
Instance Method Details
#destination ⇒ Object
The resolved destination for the message.
39 40 41 42 43 44 45 |
# File 'lib/drbdump/message.rb', line 39 def destination return @destination if @destination resolve_addresses @destination end |
#resolve_addresses ⇒ Object
Resolves source and destination addresses
50 51 52 53 54 55 56 57 58 |
# File 'lib/drbdump/message.rb', line 50 def resolve_addresses # :nodoc: resolver = @drbdump.resolver source = @packet.source resolver @source = "\"druby://#{source.sub(/\.(\d+)$/, ':\1')}\"" destination = @packet.destination resolver @destination = "\"druby://#{destination.sub(/\.(\d+)$/, ':\1')}\"" end |
#source ⇒ Object
The resolved source of the message
63 64 65 66 67 68 69 |
# File 'lib/drbdump/message.rb', line 63 def source return @source if @source resolve_addresses @source end |