Class: QuartzTorrent::UdpTrackerAnnounceResponse
- Inherits:
-
UdpTrackerResponse
- Object
- UdpTrackerResponse
- QuartzTorrent::UdpTrackerAnnounceResponse
- Defined in:
- lib/quartz_torrent/udptrackermsg.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#ips ⇒ Object
Returns the value of attribute ips.
-
#leechers ⇒ Object
Returns the value of attribute leechers.
-
#ports ⇒ Object
Returns the value of attribute ports.
-
#seeders ⇒ Object
Returns the value of attribute seeders.
Attributes inherited from UdpTrackerResponse
#action, #connectionId, #transactionId
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ UdpTrackerAnnounceResponse
constructor
A new instance of UdpTrackerAnnounceResponse.
Constructor Details
#initialize ⇒ UdpTrackerAnnounceResponse
Returns a new instance of UdpTrackerAnnounceResponse.
215 216 217 218 219 220 221 222 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 215 def initialize super @interval = nil @leechers = nil @seeders = nil @ips = [] @ports = [] end |
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval.
224 225 226 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 224 def interval @interval end |
#ips ⇒ Object
Returns the value of attribute ips.
227 228 229 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 227 def ips @ips end |
#leechers ⇒ Object
Returns the value of attribute leechers.
225 226 227 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 225 def leechers @leechers end |
#ports ⇒ Object
Returns the value of attribute ports.
228 229 230 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 228 def ports @ports end |
#seeders ⇒ Object
Returns the value of attribute seeders.
226 227 228 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 226 def seeders @seeders end |
Class Method Details
.unserialize(msg) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 230 def self.unserialize(msg) raise "Invalid connect response: it is #{msg.length} when it must be at least 20" if msg.length < 20 result = UdpTrackerAnnounceResponse.new result.action = UdpTrackerMessage::unpackNetworkOrder(msg,4) result.transactionId = UdpTrackerMessage::unpackNetworkOrder(msg[4,4],4) result.interval = UdpTrackerMessage::unpackNetworkOrder(msg[8,4],4) result.leechers = UdpTrackerMessage::unpackNetworkOrder(msg[12,4],4) result.seeders = UdpTrackerMessage::unpackNetworkOrder(msg[16,4],4) index = 20 while index+6 < msg.length result.ips.push msg[index,4] result.ports.push msg[index+4,2] index += 6 end result end |