Class: QuartzTorrent::PeerClient
- Inherits:
-
Object
- Object
- QuartzTorrent::PeerClient
- Defined in:
- lib/quartz_flow/mock_client.rb
Instance Method Summary collapse
- #addTorrent ⇒ Object
- #addTorrentByMetainfo(info) ⇒ Object
-
#initialize(ignored) ⇒ PeerClient
constructor
A new instance of PeerClient.
- #port=(p) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #torrentData(infoHash = nil) ⇒ Object
Constructor Details
#initialize(ignored) ⇒ PeerClient
Returns a new instance of PeerClient.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/quartz_flow/mock_client.rb', line 166 def initialize(ignored) @words = Words.new @torrents = {} 7.times{ addTorrent } Thread.new do while true begin @torrents.each{ |k,t| t.downloadRate += (rand(1000) - 500)} rescue puts "Exception in Mock PeerClient: #{$!}" end sleep 2 end end end |
Instance Method Details
#addTorrent ⇒ Object
198 199 200 201 |
# File 'lib/quartz_flow/mock_client.rb', line 198 def addTorrent d = makeFakeTorrentDelegate @torrents[d.infoHash] = d end |
#addTorrentByMetainfo(info) ⇒ Object
191 192 |
# File 'lib/quartz_flow/mock_client.rb', line 191 def addTorrentByMetainfo(info) end |
#port=(p) ⇒ Object
182 183 |
# File 'lib/quartz_flow/mock_client.rb', line 182 def port=(p) end |
#start ⇒ Object
185 186 |
# File 'lib/quartz_flow/mock_client.rb', line 185 def start end |
#stop ⇒ Object
188 189 |
# File 'lib/quartz_flow/mock_client.rb', line 188 def stop end |
#torrentData(infoHash = nil) ⇒ Object
194 195 196 |
# File 'lib/quartz_flow/mock_client.rb', line 194 def torrentData(infoHash = nil) @torrents end |