Class: QuartzTorrent::Request
- Inherits:
-
PeerWireMessage
- Object
- PeerWireMessage
- QuartzTorrent::Request
- Defined in:
- lib/quartz_torrent/peermsg.rb
Overview
Request message. Request a block within a piece.
Constant Summary
Constants inherited from PeerWireMessage
PeerWireMessage::MessageBitfield, PeerWireMessage::MessageCancel, PeerWireMessage::MessageChoke, PeerWireMessage::MessageExtended, PeerWireMessage::MessageHave, PeerWireMessage::MessageInterested, PeerWireMessage::MessageKeepAlive, PeerWireMessage::MessagePiece, PeerWireMessage::MessageRequest, PeerWireMessage::MessageUnchoke, PeerWireMessage::MessageUninterested
Instance Attribute Summary collapse
-
#blockLength ⇒ Object
Returns the value of attribute blockLength.
-
#blockOffset ⇒ Object
Returns the value of attribute blockOffset.
-
#pieceIndex ⇒ Object
Returns the value of attribute pieceIndex.
Attributes inherited from PeerWireMessage
Instance Method Summary collapse
-
#initialize ⇒ Request
constructor
A new instance of Request.
- #payloadLength ⇒ Object
- #serializeTo(io) ⇒ Object
- #to_s ⇒ Object
- #unserialize(payload) ⇒ Object
Methods inherited from PeerWireMessage
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
245 246 247 |
# File 'lib/quartz_torrent/peermsg.rb', line 245 def initialize super(MessageRequest) end |
Instance Attribute Details
#blockLength ⇒ Object
Returns the value of attribute blockLength.
251 252 253 |
# File 'lib/quartz_torrent/peermsg.rb', line 251 def blockLength @blockLength end |
#blockOffset ⇒ Object
Returns the value of attribute blockOffset.
250 251 252 |
# File 'lib/quartz_torrent/peermsg.rb', line 250 def blockOffset @blockOffset end |
#pieceIndex ⇒ Object
Returns the value of attribute pieceIndex.
249 250 251 |
# File 'lib/quartz_torrent/peermsg.rb', line 249 def pieceIndex @pieceIndex end |
Instance Method Details
#payloadLength ⇒ Object
253 254 255 |
# File 'lib/quartz_torrent/peermsg.rb', line 253 def payloadLength 12 end |
#serializeTo(io) ⇒ Object
257 258 259 260 |
# File 'lib/quartz_torrent/peermsg.rb', line 257 def serializeTo(io) super(io) io.write [@pieceIndex, @blockOffset, @blockLength].pack("NNN") end |
#to_s ⇒ Object
266 267 268 269 |
# File 'lib/quartz_torrent/peermsg.rb', line 266 def to_s s = super s + ": piece index=#{@pieceIndex}, block offset=#{@blockOffset}, block length=#{@blockLength}" end |
#unserialize(payload) ⇒ Object
262 263 264 |
# File 'lib/quartz_torrent/peermsg.rb', line 262 def unserialize(payload) @pieceIndex, @blockOffset, @blockLength = payload.unpack("NNN") end |