class QuartzTorrent::Piece

Piece message. Response to a Request message containing the block of data within a piece.

Attributes

blockOffset[RW]
data[RW]
pieceIndex[RW]

Public Class Methods

new() click to toggle source
Calls superclass method QuartzTorrent::PeerWireMessage::new
# File lib/quartz_torrent/peermsg.rb, line 274
def initialize
  super(MessagePiece)
end

Public Instance Methods

payloadLength() click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 282
def payloadLength
  8 + @data.length     
end
serializeTo(io) click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 286
def serializeTo(io)
  super(io)
  io.write [@pieceIndex, @blockOffset, @data].pack("NNa*")
end
to_s() click to toggle source
Calls superclass method QuartzTorrent::PeerWireMessage#to_s
# File lib/quartz_torrent/peermsg.rb, line 295
def to_s
  s = super
  s + ": piece index=#{@pieceIndex}, block offset=#{@blockOffset}"
end
unserialize(payload) click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 291
def unserialize(payload)
  @pieceIndex, @blockOffset, @data = payload.unpack("NNa*")
end