source: trunk/FACT++/scripts/doc/Subscription.js@ 14649

Last change on this file since 14649 was 14644, checked in by tbretz, 13 years ago
File size: 3.8 KB
Line 
1/**
2 * @fileOverview
3 * Documentation of a DIM service Subscription
4 */
5
6/**
7 * @class
8 *
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>
15 *
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.
21 *
22 * @param {Integer} timeout
23 * A positive integer given the initial delay in milliseconds before
24 * the thread is executed.
25 *
26 * @param {Function} function
27 * A function which is executed aftr the initial timeout.
28 *
29 * @throws
30 * <li> If number or type of arguments is wrong
31 *
32 * @example
33 * var handle = new Thread(100, function() { dim.out("Hello world!"); });
34 * handle.kill();
35 */
36function Subscription(service)
37{
38 /**
39 *
40 * The name of the service subscribed to.
41 *
42 * @constant
43 * @type String
44 *
45 */
46 this.name = service;
47
48 /**
49 *
50 * Boolean value which is set to false if the Subscription was closed.
51 *
52 * @type Boolean
53 *
54 */
55 this.isOpen = false;
56
57 /**
58 *
59 * Callback in case of event reception.
60 *
61 * To install a callback in case a new event of this Subscription
62 * was received, set this property to a function. The argument
63 * provided to the function is identical with the object returned
64 * by Subscription.get(). For the code executed, the same rules apply
65 * than for a thread created with Thread.
66 *
67 * @type Function
68 *
69 * @example
70 * subscription.onchange = function(event) { dim.out(JSON.stringify(event); };
71 *
72 */
73 this.onchange = func;
74
75 /**
76 *
77 * Returns the last received event of this subscription.
78 *
79 * @param {Integer} [timeout=0]
80 * A timeout in millisecond to wait for an event to arrive.
81 * This timeout only applied if no event has been received yet
82 * after a new Subscription has been created. If an event
83 * is already available, the event is received. If the timeout
84 * is 'null', waiting will nevr timeout until an event was received.
85 * If the timeout is less than zero, no exception will be thrown,
86 * but 'undefined' returned in case of timeout. The corresponding
87 * timeout is then Math.abs(timeout).
88 *
89 * @param {Boolean} [requireNamed=true]
90 * Usually an event is only considered complete, if also the
91 * corresponding decription is available distcibuted through
92 * the service SERVER/SERVICE_DESC. If an event has no
93 * subscription or it is not important, requireNamed can
94 * be set to false.
95 *
96 * @throws
97 * <li> If number or type of arguments is wrong
98 * <li> After a timeout, if the timeout value was greater or equal zero
99 * <li> If conversion of th received data to an event object has failed
100 *
101 * @returns {Event}
102 * If the thread was still known, true is returned, false
103 * otherwise. If the thread terminated already, false is
104 * returned.
105 *
106 */
107 this.get = function() { /* [native code] */ }
108
109 /**
110 *
111 * Unsubscribe from an existing subscription. Note that all open
112 * subscription produce network traffic and should be omitted if
113 * not needed.
114 *
115 * @returns {Boolean}
116 * true if the subscription was still open, false if it was
117 * already closed.
118 *
119 */
120 this.close() = function() { /* [native code] */ }
121}
Note: See TracBrowser for help on using the repository browser.