Class: QuartzTorrent::UdpTrackerAnnounceRequest

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

Instance Attribute Summary collapse

Attributes inherited from UdpTrackerRequest

#action, #connectionId, #transactionId

Instance Method Summary collapse

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

#downloadedObject

Returns the value of attribute downloaded.



157
158
159
# File 'lib/quartz_torrent/udptrackermsg.rb', line 157

def downloaded
  @downloaded
end

#eventObject

Returns the value of attribute event.



160
161
162
# File 'lib/quartz_torrent/udptrackermsg.rb', line 160

def event
  @event
end

#infoHashObject

Returns the value of attribute infoHash.



155
156
157
# File 'lib/quartz_torrent/udptrackermsg.rb', line 155

def infoHash
  @infoHash
end

#ipAddressObject

Returns the value of attribute ipAddress.



161
162
163
# File 'lib/quartz_torrent/udptrackermsg.rb', line 161

def ipAddress
  @ipAddress
end

#keyObject

Returns the value of attribute key.



162
163
164
# File 'lib/quartz_torrent/udptrackermsg.rb', line 162

def key
  @key
end

#leftObject

Returns the value of attribute left.



158
159
160
# File 'lib/quartz_torrent/udptrackermsg.rb', line 158

def left
  @left
end

#numWantObject

Returns the value of attribute numWant.



163
164
165
# File 'lib/quartz_torrent/udptrackermsg.rb', line 163

def numWant
  @numWant
end

#peerIdObject

Returns the value of attribute peerId.



156
157
158
# File 'lib/quartz_torrent/udptrackermsg.rb', line 156

def peerId
  @peerId
end

#portObject

Returns the value of attribute port.



164
165
166
# File 'lib/quartz_torrent/udptrackermsg.rb', line 164

def port
  @port
end

#uploadedObject

Returns the value of attribute uploaded.



159
160
161
# File 'lib/quartz_torrent/udptrackermsg.rb', line 159

def uploaded
  @uploaded
end

Instance Method Details

#serializeObject



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