Changeset 6210


Ignore:
Timestamp:
Jun 17, 2008, 4:47:20 AM (13 years ago)
Author:
charles
Message:

(rpc) tweaks to the rpc spec.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/rpc-spec.txt

    r6203 r6210  
    12122.  Message Format
    1313
    14    Messages are formatted in a subset of JSON that understands
    15    arrays, maps, strings, and whole numbers with no exponentials --
    16    in short, the subset of JSON easily represented as bencoded data.
    17    Floating-point numbers are represented as strings.
    18    Booleans are represented as integers where 0 is false and 1 is true.
    19 
    20    Messages are represented as JSON objects.  There are two types:
     14   Messages are formatted in a subset of JSON easily represented
     15   as bencoded data -- arrays, objects, strings, and numbers.
     16   Booleans are represented as numbers where 0 is false and 1 is true.
     17
     18   Messages are formatted as objects.  There are two types:
    2119   requests (described in 2.1) and responses (described in 2.2).
    2220
     
    4644
    4745   The URL notation works as follows:
    48    (1) Any key not "tag" or "method" is assumed to be in "arguments".
     46   (1) Any key not "tag" or "method" is treated as an argument.
    4947   (2) The "arguments" key isn't needed, since data isn't nested.
    50    (3) If the entire value in a key/value pair can be parsed as an integer,
    51        it's parsed into a JSON number.
    52        Otherwise, if the value can be parsed as comma-delimited integers,
    53        it's parsed into a JSON array of integers.
    54        Otherwise, the value is treated as a string.
     48   (3) If the value in a key/value pair can be parsed as a number, then it is.
     49       Otherwise if it can be parsed as an array of numbers, then it is.
     50       Otherwise, it's parsed as a string.
    5551
    5652   Examples:
     
    8278   The request supports four arguments:
    8379
    84    (1) "ids", as described in section 3.1.
    85    (2) A required "fields" number as described in the table below
    86    (3) An optional "sort" string whose value should be one of:
     80   (1) An optional "ids" array as described in section 3.1.
     81   (2) A required "fields" number as described in the table below.
     82   (3) An optional "sort" string whose value should be one of
    8783       "activity", "age", "id", "name", "progress", "ratio", "state", "tracker".
     84       The default value is "id".
    8885   (4) An optional "sort-ascending" 'boolean'.
    8986       This is only used if "sort-method" is supplied.
    9087       Its default value is 'true'.
    91    (5) An optional "filter" string whose value may be one of:
    92        "active", "all", "downloading", "paused", "seeding"
     88   (5) An optional "filter" string whose value may be one of
     89       "active", "all", "downloading", "paused", "seeding".
     90       The default value is "all".
    9391
    9492   The respons supports two arguments:
     
    111109                      | number   | status                 | tr_stat
    112110                      | number   | swarmSpeed             | tr_stat
     111                      | 'double' | uploadRatio            | tr_stat
    113112                      | number   | webseedsSendingToUs    | tr_stat
    114113   -------------------+----------+------------------------+-------------
     
    153152                      | number   | uploadLimitMode        | tr_torrent
    154153   -------------------+----------+------------------------+-------------
    155    peers, 256         | object   | peersFrom              | tr_stat
    156                       +----------+------------------------+-------------
    157                       | peersFrom contains:
    158                       +----------+------------------------+-------------
    159                       | number   | cache                  | tr_stat
    160                       | number   | incoming               | tr_stat
    161                       | number   | pex                    | tr_stat
    162                       | number   | tracker                | tr_stat
     154   peers, 256         | number   | fromCache              | tr_stat
     155                      | number   | fromIncoming           | tr_stat
     156                      | number   | fromPex                | tr_stat
     157                      | number   | fromTracker            | tr_stat
    163158   -------------------+----------+------------------------+-------------
    164159   scrape, 512        | number   | lastScrapeTime         | tr_stat
     
    170165                      | number   | haveValid              | tr_stat
    171166                      | number   | leftUntilDone          | tr_stat
    172                       | 'double' | percentComplete        | tr_stat
    173                       | 'double' | percentDone            | tr_stat
    174                       | 'double' | ratio                  | tr_stat
    175167                      | number   | sizeWhenDone           | tr_stat
    176                       | number   | totalSize              | tr_stat
     168                      | number   | totalSize              | tr_info
    177169   -------------------+----------+------------------------+-------------
    178170   tracker stats,     | number   | leechers               | tr_stat
     
    192184                      +----------+--------------------------------------
    193185                      | webseeds contains:
    194                       | an array of weseed url strings
     186                      +----------+------------------------+-------------
     187                      | an array of weseed URL strings    | tr_info
    195188   -------------------+----------+------------------------+-------------
    196189
     
    198191   Example:
    199192
    200    Say we want to get the ratio and name of torrents 7 and 10.
    201    name is in the "id" section (32) and ratio is in "size" (1024),
     193   Say we want to get the name and total size torrents 7 and 10.
     194   name is in the "id" section (32) and total size is in "size" (1024),
    202195   so the "fields" argument will be 32 + 1024 == 1056.
    203196
     
    227220                   "leftUntilDone", 0,
    228221                   "name": "Fedora x86_64 DVD",
    229                    "percentComplete", "0.8010",
    230                    "percentDone", "0.8010",
    231                    "ratio", "0.604034",
    232222                   "sizeWhenDone", 34983493932,
    233223                   "totalSize", 34983493932,
     
    240230                   "leftUntilDone", 0,
    241231                   "name": "Ubuntu x86_64 DVD",
    242                    "percentComplete", "1.0000",
    243                    "percentDone", "1.0000",
    244                    "ratio", "2.23222",
    245232                   "sizeWhenDone", 9923890123,
    246233                   "totalSize", 9923890123,
  • trunk/libtransmission/rpc.c

    r6203 r6210  
    254254        tr_bencDictAddInt( d, "status", st->status );
    255255        tr_bencDictAddDouble( d, "swarmSpeed", st->swarmSpeed );
     256        tr_bencDictAddDouble( d, "ratio", st->ratio );
    256257        tr_bencDictAddInt( d, "webseedsSendingToUs", st->webseedsSendingToUs );
    257258    }
     
    306307
    307308    if( fields & TR_RPC_TORRENT_FIELD_PEERS ) {
    308         const int * from = st->peersFrom;
    309         tr_benc * f;
    310         f = tr_bencDictAddDict( d, "peersFrom", 4 );
    311             tr_bencDictAddInt( f, "cache",    from[TR_PEER_FROM_CACHE] );
    312             tr_bencDictAddInt( f, "incoming", from[TR_PEER_FROM_INCOMING] );
    313             tr_bencDictAddInt( f, "pex",      from[TR_PEER_FROM_PEX] );
    314             tr_bencDictAddInt( f, "tracker",  from[TR_PEER_FROM_TRACKER] );
     309        const int * f = st->peersFrom;
     310        tr_bencDictAddInt( d, "fromCache",    f[TR_PEER_FROM_CACHE] );
     311        tr_bencDictAddInt( d, "fromIncoming", f[TR_PEER_FROM_INCOMING] );
     312        tr_bencDictAddInt( d, "fromPex",      f[TR_PEER_FROM_PEX] );
     313        tr_bencDictAddInt( d, "fromTracker",  f[TR_PEER_FROM_TRACKER] );
    315314    }
    316315
     
    326325        tr_bencDictAddInt( d, "haveValid", st->haveValid );
    327326        tr_bencDictAddInt( d, "leftUntilDone", st->leftUntilDone );
    328         tr_bencDictAddDouble( d, "percentComplete", st->percentComplete );
    329         tr_bencDictAddDouble( d, "percentDone", st->percentDone );
    330         tr_bencDictAddDouble( d, "ratio", st->ratio );
    331327        tr_bencDictAddInt( d, "sizeWhenDone", st->sizeWhenDone );
    332328        tr_bencDictAddInt( d, "totalSize", inf->totalSize );
Note: See TracChangeset for help on using the changeset viewer.