Class: QuartzTorrent::Have
- Inherits:
-
PeerWireMessage
- Object
- PeerWireMessage
- QuartzTorrent::Have
- Defined in:
- lib/quartz_torrent/peermsg.rb
Overview
Have message. Sent to all connected peers to notify that we have completed downloading the specified 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
-
#pieceIndex ⇒ Object
Returns the value of attribute pieceIndex.
Attributes inherited from PeerWireMessage
Instance Method Summary collapse
-
#initialize ⇒ Have
constructor
A new instance of Have.
- #payloadLength ⇒ Object
- #serializeTo(io) ⇒ Object
- #to_s ⇒ Object
- #unserialize(payload) ⇒ Object
Methods inherited from PeerWireMessage
Constructor Details
#initialize ⇒ Have
Returns a new instance of Have.
195 196 197 |
# File 'lib/quartz_torrent/peermsg.rb', line 195 def initialize super(MessageHave) end |
Instance Attribute Details
#pieceIndex ⇒ Object
Returns the value of attribute pieceIndex.
199 200 201 |
# File 'lib/quartz_torrent/peermsg.rb', line 199 def pieceIndex @pieceIndex end |
Instance Method Details
#payloadLength ⇒ Object
201 202 203 |
# File 'lib/quartz_torrent/peermsg.rb', line 201 def payloadLength 4 end |
#serializeTo(io) ⇒ Object
205 206 207 208 |
# File 'lib/quartz_torrent/peermsg.rb', line 205 def serializeTo(io) super(io) io.write [@pieceIndex].pack("N") end |
#to_s ⇒ Object
214 215 216 217 |
# File 'lib/quartz_torrent/peermsg.rb', line 214 def to_s s = super s + ": piece index=#{@pieceIndex}" end |
#unserialize(payload) ⇒ Object
210 211 212 |
# File 'lib/quartz_torrent/peermsg.rb', line 210 def unserialize(payload) @pieceIndex = payload.unpack("N")[0] end |