class QuartzTorrent::ExtendedHandshake

An Extended Handshake message. Used to negotiate supported extensions.

Attributes

dict[RW]

Public Class Methods

new() click to toggle source
Calls superclass method QuartzTorrent::Extended::new
# File lib/quartz_torrent/peermsg.rb, line 374
def initialize
  super()
  @dict = {}
  @extendedMessageId = 0
end

Public Instance Methods

serializeTo(io) click to toggle source
Calls superclass method QuartzTorrent::Extended#serializeTo
# File lib/quartz_torrent/peermsg.rb, line 394
def serializeTo(io)
  super(io)
  io.write dict.bencode
end
unserialize(payload) click to toggle source
Calls superclass method QuartzTorrent::Extended#unserialize
# File lib/quartz_torrent/peermsg.rb, line 382
def unserialize(payload)
  super(payload)
  payload = payload[1,payload.length]
  begin
    @dict = payload.bdecode
  rescue
    e = RuntimeError.new("Error bdecoding payload '#{payload}' (payload length = #{payload.length})")
    e.set_backtrace($!.backtrace)
    raise e
  end
end

Private Instance Methods

extendedMsgPayloadLength() click to toggle source
# File lib/quartz_torrent/peermsg.rb, line 400
def extendedMsgPayloadLength
  dict.bencode.length
end