winlin
Committed by GitHub

Merge pull request #756 from eagle-zhang/develop

Clients Api support start and count
@@ -791,6 +791,24 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) @@ -791,6 +791,24 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
791 // e.g. /api/v1/clients/100 pattern= /api/v1/clients/, client_id=100 791 // e.g. /api/v1/clients/100 pattern= /api/v1/clients/, client_id=100
792 int cid = r->parse_rest_id(entry->pattern); 792 int cid = r->parse_rest_id(entry->pattern);
793 793
  794 + std::string start = r->query_get("start");
  795 + std::string count = r->query_get("count");
  796 + int cst = 0;
  797 + int cct = 10;
  798 + if(!start.empty()){
  799 + cst = atoi(start.c_str());
  800 + }
  801 + if(!count.empty()){
  802 + cct = atoi(count.c_str());
  803 + }
  804 + if(cst<0){
  805 + cst = 0;
  806 + }
  807 + if(cct<=0){
  808 + cct = 10;
  809 + }
  810 +
  811 +
794 SrsStatisticClient* client = NULL; 812 SrsStatisticClient* client = NULL;
795 if (cid >= 0 && (client = stat->find_client(cid)) == NULL) { 813 if (cid >= 0 && (client = stat->find_client(cid)) == NULL) {
796 ret = ERROR_RTMP_CLIENT_NOT_FOUND; 814 ret = ERROR_RTMP_CLIENT_NOT_FOUND;
@@ -809,7 +827,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) @@ -809,7 +827,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
809 SrsJsonArray* data = SrsJsonAny::array(); 827 SrsJsonArray* data = SrsJsonAny::array();
810 obj->set("clients", data); 828 obj->set("clients", data);
811 829
812 - if ((ret = stat->dumps_clients(data, 0, 10)) != ERROR_SUCCESS) { 830 + if ((ret = stat->dumps_clients(data, cst, cct)) != ERROR_SUCCESS) {
813 return srs_api_response_code(w, r, ret); 831 return srs_api_response_code(w, r, ret);
814 } 832 }
815 } else { 833 } else {