forked from PearInc/PearPlayer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
谢庭
authored and
谢庭
committed
Dec 18, 2017
1 parent
66a8c19
commit 20a21ed
Showing
8 changed files
with
1,851 additions
and
213 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
### 2.4.7 | ||
- 修改流量上报接口端口号 | ||
|
||
### 2.4.6 | ||
- 增加节点流量上报功能 | ||
- 修正速度统计的bug | ||
|
||
### 2.4.5 | ||
- 优化调度算法,显著提高下载速度 | ||
- 解决不传入opts报错的bug | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Created by xieting on 2017/12/7. | ||
*/ | ||
|
||
var debug = require('debug')('pear:reporter'); | ||
var axios = require('axios'); | ||
|
||
axios.defaults.baseURL = 'https://statdapi.webrtc.win:9801'; | ||
|
||
|
||
var totalReportTraffic = 0; | ||
|
||
function reportTraffic(uuid, fileSize, traffics) { | ||
var temp = 0; | ||
for (var i=0; i<traffics.length; ++i) { | ||
temp += traffics[i].traffic; | ||
} | ||
if (temp >= totalReportTraffic + 10485760) { //如果流量增加大于10 | ||
var body = JSON.stringify({ | ||
uuid: uuid, | ||
size: Number(fileSize), | ||
traffic: traffics | ||
}); | ||
axios({ | ||
method: 'post', | ||
url: '/traffic', | ||
data: body | ||
}) | ||
.then(function(response) { | ||
debug('reportTraffic response:'+JSON.stringify(response)+' temp:'+temp+' totalReportTraffic:'+totalReportTraffic); | ||
if (response.status == 200) { | ||
totalReportTraffic = temp; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function finalyReportTraffic(uuid, fileSize, traffics) { | ||
var body = JSON.stringify({ | ||
uuid: uuid, | ||
size: Number(fileSize), | ||
traffic: traffics | ||
}); | ||
axios({ | ||
method: 'post', | ||
url: '/traffic', | ||
data: body | ||
}) | ||
.then(function(response) { | ||
if (response.status == 200) { | ||
debug('finalyReportTraffic'); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = { | ||
|
||
reportTraffic : reportTraffic, | ||
finalyReportTraffic: finalyReportTraffic | ||
}; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters