Class: QuartzTorrent::UdpTrackerConnectResponse

Inherits:
UdpTrackerResponse show all
Defined in:
lib/quartz_torrent/udptrackermsg.rb

Instance Attribute Summary

Attributes inherited from UdpTrackerResponse

#action, #connectionId, #transactionId

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUdpTrackerConnectResponse

Returns a new instance of UdpTrackerConnectResponse.



112
113
114
# File 'lib/quartz_torrent/udptrackermsg.rb', line 112

def initialize
  super
end

Class Method Details

.tohex(str) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/quartz_torrent/udptrackermsg.rb', line 126

def self.tohex(str)  
  result = ""
  str.each_byte do |b|
    result << b.to_s(16)
  end
  result
end

.unserialize(msg) ⇒ Object



116
117
118
119
120
121
122
123
124
# File 'lib/quartz_torrent/udptrackermsg.rb', line 116

def self.unserialize(msg)
  raise "Invalid connect response: it is #{msg.length} when it must be at least 16" if msg.length < 16
  result = UdpTrackerConnectResponse.new
  result.action = UdpTrackerMessage::unpackNetworkOrder(msg,4)
  result.transactionId = UdpTrackerMessage::unpackNetworkOrder(msg[4,4],4)
  result.connectionId = UdpTrackerMessage::unpackNetworkOrder(msg[8,8],8)
  raise "Invalid connect response: action is not connect" if result.action != UdpTrackerMessage::ActionConnect
  result
end