class QuartzTorrent::Extended
Extended
message. These are extra messages not defined in the base protocol.
Attributes
extendedMessageId[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
QuartzTorrent::PeerWireMessage::new
# File lib/quartz_torrent/peermsg.rb, line 332 def initialize super(MessageExtended) end
Private Class Methods
classForMessage(id, peerExtendedMessageList)
click to toggle source
Given an extended message id, return the subclass of Extended
for that message. peerExtendedMessageList should be an array indexed by extended message id that returns a subclass of Extended
# File lib/quartz_torrent/peermsg.rb, line 364 def self.classForMessage(id, peerExtendedMessageList) return ExtendedHandshake if id == 0 raise "Unknown extended peer message id #{id}" if id > peerExtendedMessageList peerExtendedMessageMap[id] end
Public Instance Methods
payloadLength()
click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 338 def payloadLength 1 + extendedMsgPayloadLength end
serializeTo(io)
click to toggle source
Calls superclass method
QuartzTorrent::PeerWireMessage#serializeTo
# File lib/quartz_torrent/peermsg.rb, line 346 def serializeTo(io) super(io) io.write [@extendedMessageId].pack("C") end
to_s()
click to toggle source
Calls superclass method
QuartzTorrent::PeerWireMessage#to_s
# File lib/quartz_torrent/peermsg.rb, line 351 def to_s s = super s + ": extendedMessageId=#{@extendedMessageId}" end
unserialize(payload)
click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 342 def unserialize(payload) @extendedMessageId = payload.unpack("C") end
Protected Instance Methods
extendedMsgPayloadLength()
click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 357 def extendedMsgPayloadLength raise "Subclasses of Extended must implement extendedMsgPayloadLength" end