Class: QuartzTorrent::Cancel

Inherits:
PeerWireMessage show all
Defined in:
lib/quartz_torrent/peermsg.rb

Overview

Cancel message. Cancel an outstanding request.

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

Attributes inherited from PeerWireMessage

#messageId

Instance Method Summary collapse

Methods inherited from PeerWireMessage

#length

Constructor Details

#initializeCancel

Returns a new instance of Cancel.



303
304
305
# File 'lib/quartz_torrent/peermsg.rb', line 303

def initialize
  super(MessageCancel)
end

Instance Attribute Details

#blockLengthObject

Returns the value of attribute blockLength.



309
310
311
# File 'lib/quartz_torrent/peermsg.rb', line 309

def blockLength
  @blockLength
end

#blockOffsetObject

Returns the value of attribute blockOffset.



308
309
310
# File 'lib/quartz_torrent/peermsg.rb', line 308

def blockOffset
  @blockOffset
end

#pieceIndexObject

Returns the value of attribute pieceIndex.



307
308
309
# File 'lib/quartz_torrent/peermsg.rb', line 307

def pieceIndex
  @pieceIndex
end

Instance Method Details

#payloadLengthObject



311
312
313
# File 'lib/quartz_torrent/peermsg.rb', line 311

def payloadLength
  12
end

#serializeTo(io) ⇒ Object



315
316
317
318
# File 'lib/quartz_torrent/peermsg.rb', line 315

def serializeTo(io)
  super(io)
  io.write [@pieceIndex, @blockOffset, @blockLength].pack("NNN")
end

#to_sObject



324
325
326
327
# File 'lib/quartz_torrent/peermsg.rb', line 324

def to_s
  s = super
  s + ": piece index=#{@pieceIndex}, block offset=#{@blockOffset}, block length=#{@blockLength}"
end

#unserialize(payload) ⇒ Object



320
321
322
# File 'lib/quartz_torrent/peermsg.rb', line 320

def unserialize(payload)
  @pieceIndex, @blockOffset, @blockLength = payload.unpack("NNN")
end