Class: QuartzTorrent::UdpTrackerAnnounceRequest
- Inherits:
-
UdpTrackerRequest
- Object
- UdpTrackerRequest
- QuartzTorrent::UdpTrackerAnnounceRequest
- Defined in:
- lib/quartz_torrent/udptrackermsg.rb
Instance Attribute Summary collapse
-
#downloaded ⇒ Object
Returns the value of attribute downloaded.
-
#event ⇒ Object
Returns the value of attribute event.
-
#infoHash ⇒ Object
Returns the value of attribute infoHash.
-
#ipAddress ⇒ Object
Returns the value of attribute ipAddress.
-
#key ⇒ Object
Returns the value of attribute key.
-
#left ⇒ Object
Returns the value of attribute left.
-
#numWant ⇒ Object
Returns the value of attribute numWant.
-
#peerId ⇒ Object
Returns the value of attribute peerId.
-
#port ⇒ Object
Returns the value of attribute port.
-
#uploaded ⇒ Object
Returns the value of attribute uploaded.
Attributes inherited from UdpTrackerRequest
#action, #connectionId, #transactionId
Instance Method Summary collapse
-
#initialize(connectionId) ⇒ UdpTrackerAnnounceRequest
constructor
A new instance of UdpTrackerAnnounceRequest.
- #serialize ⇒ Object
Constructor Details
#initialize(connectionId) ⇒ UdpTrackerAnnounceRequest
Returns a new instance of UdpTrackerAnnounceRequest.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 136 def initialize(connectionId) super() @connectionId = connectionId @action = UdpTrackerMessage::ActionAnnounce @infoHash = nil @peerId = nil @downloaded = nil @left = nil @uploaded = nil @event = nil # 0 means allow tracker to assume the sender's IP address is the one it's looking for # http://www.rasterbar.com/products/libtorrent/udp_tracker_protocol.html @ipAddress = 0 @key = rand(0xffffffff) # Number of peers requested: default. @numWant = -1 @port = nil end |
Instance Attribute Details
#downloaded ⇒ Object
Returns the value of attribute downloaded.
157 158 159 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 157 def downloaded @downloaded end |
#event ⇒ Object
Returns the value of attribute event.
160 161 162 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 160 def event @event end |
#infoHash ⇒ Object
Returns the value of attribute infoHash.
155 156 157 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 155 def infoHash @infoHash end |
#ipAddress ⇒ Object
Returns the value of attribute ipAddress.
161 162 163 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 161 def ipAddress @ipAddress end |
#key ⇒ Object
Returns the value of attribute key.
162 163 164 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 162 def key @key end |
#left ⇒ Object
Returns the value of attribute left.
158 159 160 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 158 def left @left end |
#numWant ⇒ Object
Returns the value of attribute numWant.
163 164 165 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 163 def numWant @numWant end |
#peerId ⇒ Object
Returns the value of attribute peerId.
156 157 158 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 156 def peerId @peerId end |
#port ⇒ Object
Returns the value of attribute port.
164 165 166 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 164 def port @port end |
#uploaded ⇒ Object
Returns the value of attribute uploaded.
159 160 161 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 159 def uploaded @uploaded end |
Instance Method Details
#serialize ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/quartz_torrent/udptrackermsg.rb', line 196 def serialize result = UdpTrackerMessage::packAsNetworkOrder(@connectionId, 8) result << UdpTrackerMessage::packAsNetworkOrder(@action, 4) result << UdpTrackerMessage::packAsNetworkOrder(@transactionId, 4) result << infoHash result << peerId result << UdpTrackerMessage::packAsNetworkOrder(@downloaded, 8) result << UdpTrackerMessage::packAsNetworkOrder(@left, 8) result << UdpTrackerMessage::packAsNetworkOrder(@uploaded, 8) result << UdpTrackerMessage::packAsNetworkOrder(@event, 4) result << UdpTrackerMessage::packAsNetworkOrder(@ipAddress, 4) result << UdpTrackerMessage::packAsNetworkOrder(@key, 4) result << UdpTrackerMessage::packAsNetworkOrder(@numWant, 4) result << UdpTrackerMessage::packAsNetworkOrder(@port, 2) result end |