Skip to content

Commit

Permalink
增加流量统计
Browse files Browse the repository at this point in the history
  • Loading branch information
coderyi committed Nov 6, 2015
1 parent 203e6a2 commit 538b9b6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
8 changes: 8 additions & 0 deletions NetworkEye/NetworkEye/NEHTTPEye.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ - (void)stopLoading {
if ([self.response.MIMEType isEqualToString:@"application/json"]) {
ne_HTTPModel.receiveJSONData=[self responseJSON];
}
double flowCount=[[[NSUserDefaults standardUserDefaults] objectForKey:@"flowCount"] doubleValue];
if (!flowCount) {
flowCount=0.0;
}
flowCount=flowCount+self.response.expectedContentLength/(1024.0*1024.0);

[[NSUserDefaults standardUserDefaults] setDouble:flowCount forKey:@"flowCount"];

[[NEHTTPModelManager defaultManager] addModel:ne_HTTPModel error:nil];
}

Expand Down
2 changes: 1 addition & 1 deletion NetworkEye/NetworkEye/NEHTTPEyeDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ - (void)setupAttributedString{
NSFontAttributeName : detailFont,
NSForegroundColorAttributeName: detailColor
}];
responseExpectedContentLengthDetail = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n",_model.responseExpectedContentLength]
responseExpectedContentLengthDetail = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%.2lfKB\n",[_model.responseExpectedContentLength doubleValue]/1024.0]
attributes:@{
NSFontAttributeName : detailFont,
NSForegroundColorAttributeName: detailColor
Expand Down
13 changes: 10 additions & 3 deletions NetworkEye/NetworkEye/NEHTTPEyeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ - (void)viewDidLoad {
}





UILabel *titleLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 25)];
tableView1.tableHeaderView=titleLabel;
titleLabel.textColor=[UIColor colorWithRed:0.24f green:0.51f blue:0.78f alpha:1.00f];
titleLabel.font=[UIFont systemFontOfSize:12];
titleLabel.textAlignment=NSTextAlignmentCenter;
double flowCount=[[[NSUserDefaults standardUserDefaults] objectForKey:@"flowCount"] doubleValue];
if (!flowCount) {
flowCount=0.0;
}
titleLabel.text=[NSString stringWithFormat:@"App流量共计%.1lfMB",flowCount];
tableView1.dataSource=self;
tableView1.delegate=self;

Expand Down
Binary file added NetworkEye/Resources/networkeye1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

NetworkEye是一个网络调试库,可以监控App内所有HTTP请求并显示请求相关的所有信息,方便App开发的网络调试。

可以检测到包括网页,NSURLConnecttion,NSURLSession,AFNetworking,第三方库,第三方SDK等的HTTP请求,非常方便实用。
可以检测到包括网页,NSURLConnecttion,NSURLSession,AFNetworking,第三方库,第三方SDK等的HTTP请求,非常方便实用。并且可以统计App内流量

NetworkEye,a iOS network debug library,It can monitor all HTTP requests within the App and displays all information related to the request.
#### Podfile
Expand Down Expand Up @@ -47,7 +47,7 @@ Aspects用于摇一摇手势,FMDB用于存储监控数据,SQLCipher用于加

NetworkEye的监控数据界面如图:

<img src="https://raw.githubusercontent.com/coderyi/NetworkEye/master/NetworkEye/Resources/networkeye1.png" width="320" height="570">
<img src="https://raw.githubusercontent.com/coderyi/NetworkEye/master/NetworkEye/Resources/networkeye1_1.png" width="320" height="570">

<img src="https://raw.githubusercontent.com/coderyi/NetworkEye/master/NetworkEye/Resources/networkeye2.png" width="320" height="570">

Expand Down

0 comments on commit 538b9b6

Please sign in to comment.