mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge pull request #756 from eagle-zhang/develop
Clients Api support start and count
This commit is contained in:
commit
f15fb27745
1 changed files with 19 additions and 1 deletions
|
@ -791,6 +791,24 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||||
// e.g. /api/v1/clients/100 pattern= /api/v1/clients/, client_id=100
|
// e.g. /api/v1/clients/100 pattern= /api/v1/clients/, client_id=100
|
||||||
int cid = r->parse_rest_id(entry->pattern);
|
int cid = r->parse_rest_id(entry->pattern);
|
||||||
|
|
||||||
|
std::string start = r->query_get("start");
|
||||||
|
std::string count = r->query_get("count");
|
||||||
|
int cst = 0;
|
||||||
|
int cct = 10;
|
||||||
|
if(!start.empty()){
|
||||||
|
cst = atoi(start.c_str());
|
||||||
|
}
|
||||||
|
if(!count.empty()){
|
||||||
|
cct = atoi(count.c_str());
|
||||||
|
}
|
||||||
|
if(cst<0){
|
||||||
|
cst = 0;
|
||||||
|
}
|
||||||
|
if(cct<=0){
|
||||||
|
cct = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SrsStatisticClient* client = NULL;
|
SrsStatisticClient* client = NULL;
|
||||||
if (cid >= 0 && (client = stat->find_client(cid)) == NULL) {
|
if (cid >= 0 && (client = stat->find_client(cid)) == NULL) {
|
||||||
ret = ERROR_RTMP_CLIENT_NOT_FOUND;
|
ret = ERROR_RTMP_CLIENT_NOT_FOUND;
|
||||||
|
@ -809,7 +827,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||||
SrsJsonArray* data = SrsJsonAny::array();
|
SrsJsonArray* data = SrsJsonAny::array();
|
||||||
obj->set("clients", data);
|
obj->set("clients", data);
|
||||||
|
|
||||||
if ((ret = stat->dumps_clients(data, 0, 10)) != ERROR_SUCCESS) {
|
if ((ret = stat->dumps_clients(data, cst, cct)) != ERROR_SUCCESS) {
|
||||||
return srs_api_response_code(w, r, ret);
|
return srs_api_response_code(w, r, ret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue