Changes between Initial Version and Version 1 of TrickleApi


Ignore:
Timestamp:
Apr 19, 2007, 8:54:06 PM (17 years ago)
Author:
KSMarksPsych
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TrickleApi

    v1 v1  
     1= Trickle message API =
     2       
     3The interface for [http://boinc.berkeley.edu/trickle.php trickle messages] includes both client-side and server-side components.
     4
     5== Client-side API ==
     6
     7To send a trickle-up message, call
     8
     9{{{
     10int boinc_send_trickle_up(char* variety, char* text)
     11}}}
     12
     13To receive a trickle-down message, call
     14
     15{{{
     16int boinc_receive_trickle_down(char* buf, int len)
     17}}}
     18
     19This returns true (nonzero) if there was a message.
     20
     21== Server-side API ==
     22
     23To handle trickle-up messages, use a 'trickle_handler' daemon. This is a program, based on sched/trickle_handler.C, linked with a function
     24
     25{{{
     26int handle_trickle(MSG_FROM_HOST&);
     27
     28struct MSG_FROM_HOST {
     29    int create_time;
     30    int hostid;
     31    char variety[256];              // project-defined; what kind of msg
     32    char xml[MSG_FROM_HOST_BLOB_SIZE];
     33};
     34}}}
     35
     36This function should return zero if the message was handled successfully; otherwise it will be retried later. The 'hostid' field identifies the host from which the message was sent. The daemon must be passed a '-variety X' command-line argument, telling it what kind of messages to handle. The daemon should be specified in the [http://boinc.berkeley.edu/project_daemons.php project configuration file].
     37
     38To send send trickle-down messages (from a trickle handler daemon or other program) you must insert a record in the 'msg_to_host' table. From C/C++, this is done as follows:
     39
     40{{{
     41DB_MSG_TO_HOST mth;
     42
     43mth.clear();
     44mth.create_time = time(0);
     45mth.hostid = hostid;
     46sprintf(mth.xml,
     47    "<trickle_down>\n"
     48    "   <result_name>%s</result_name>\n"
     49    "   ...\n"
     50    "</trickle_down>\n",
     51    ...
     52);
     53retval = mth.insert();
     54}}}
     55
     56To send trickle-down messages, a project must include the line
     57
     58{{{
     59<msg_to_host/>
     60}}}
     61
     62in the [http://boinc.berkeley.edu/configuration.php configuration] (config.xml) file.