Ignore:
Timestamp:
11/18/12 22:46:36 (12 years ago)
Author:
tbretz
Message:
Updated
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/scripts/doc/Subscription.js

    r14644 r14654  
    77 * @class
    88 *
    9  * Creates a handle to a new thread. The handle can be used to
    10  * kill the thread or be ignored. The function provided is
    11  * executed after an initial timeout. Note that although this
    12  * looks similar to the setTimeout in web-browsers, after started,
    13  * the thread will not run until completion but run in parallel to
    14  * the executed script.<P>
     9 * Subscription to a DIM service.
    1510 *
    16  * Note that although the object is created with 'new' and there
    17  * is a 'delete' is JavaScript, it will not call any kind of
    18  * destructor. To close a Subscription you have to explicitly call
    19  * the close() member function. 'delete' in JavaScript is only
    20  * to remove a property from an Object.
     11 * This class represents the subscription to a DIM service. Received
     12 * events are first copied to an even queue internally, to avoid
     13 * any processing blocking the DIM thread (which could block the
     14 * whole network as a result). Then the events are processed.
     15 * If a callback is installed, the processing will take place in
     16 * another JavaScript thread. Physically it will run synchronously
     17 * with the other JavaScript threads. However, the processing blocks
     18 * event processing. Consequetly, processing should on average be
     19 * faster than the frequency with which events arrive to ensure they
     20 * will not fill up the memory and possible reactions to there
     21 * contents will happen within a reasonable time and not delayed
     22 * too much.
    2123 *
    22  * @param {Integer} timeout
    23  *    A positive integer given the initial delay in milliseconds before
    24  *    the thread is executed.
     24 * @param {String} service
     25 *    Name of the DIM service to which a subscription should be made.
     26 *    Usully of the form SERVER/SUBSCRIPTION.
    2527 *
    26  * @param {Function} function
    27  *    A function which is executed aftr the initial timeout.
     28 * @param {Function} [callback]
     29 *    An optional function which is set as 'onchange' property.
     30 *    This can avoid to loose th first event after the subscription
     31 *    before the callback is set by the 'onchange' property (which
     32 *    is very unlikely).
    2833 *
    2934 * @throws
    30  *    <li> If number or type of arguments is wrong
     35 *    <li>If number or type of arguments is wrong
     36 *    <li>If an open subscription to the same service already exists.
    3137 *
    3238 * @example
    33  *    var handle = new Thread(100, function() { dim.out("Hello world!"); });
    34  *    handle.kill();
     39 *    var handle1 = new Subscription("MAGIC_WEATHER/DATA");
     40 *    var handle2 = new Subscription("TNG_WEATHER/DATA", function(evt) { dim.out(JSON.stringify(evt)); });
     41 *    ...
     42 *    handle2.close();
     43 *    handle1.close();
    3544 */
    36 function Subscription(service)
     45function Subscription(service, callback)
    3746{
    3847    /**
     
    6877     *
    6978     * @example
    70      *     subscription.onchange = function(event) { dim.out(JSON.stringify(event); };
     79     *     handle.onchange = function(event) { dim.out(JSON.stringify(event); };
    7180     *
    7281     */
    73     this.onchange = func;
     82    this.onchange = callback;
    7483
    7584    /**
Note: See TracChangeset for help on using the changeset viewer.