Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
resource requester: force requesting to CDN on decodingError
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioribeiro committed Oct 23, 2014
1 parent 1ccb92b commit 4963c44
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/resource_requester.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@ class ResourceRequester extends BaseObject {
this.cdnRequester = new CDNRequester()
this.p2pManager = new P2PManager(params)
this.isInitialBuffer = true
this.sameSource = 0
this.decodingError = false
}

requestResource(resource, bufferLength, callback) {
if (resource === this.resource) {
this.sameSource += 1
}
this.resource = resource
this.callback = callback
if (bufferLength < Settings.lowBufferLength || this.isInitialBuffer || _.size(this.p2pManager.swarm.utils.contributors) === 0 || this.sameSource >= 3) {
if (this.decodingError) {
this.requestToCDN()
} else if (bufferLength < Settings.lowBufferLength || this.isInitialBuffer || _.size(this.p2pManager.swarm.utils.contributors) === 0) {
this.requestToCDN()
this.sameSource = 0
} else {
this.requestToP2P()
}
}

requestToCDN() {
log.info("getting from CDN: " + this.resource)
this.cdnRequester.requestResource(this.resource, this.callback)
}

Expand Down

0 comments on commit 4963c44

Please sign in to comment.