source: branches/FACT++_scripts_refactoring/tests_n_examples/test_double_subscription.js@ 19921

Last change on this file since 19921 was 14887, checked in by neise, 12 years ago
I think I moved the tests and examples into its own folder, in order to keep the scripts folder tidy
File size: 962 bytes
Line 
1'use strict';
2
3// Subscribe to the the services (returns a handle to each of them)
4var w = new Subscription("MAGIC_WEATHER/DATA");
5
6// Name which corresponds to handle
7console.out(w.name);
8
9// Wait until a valid service object is in the internal buffer
10while (!w.get(-1))
11 v8.sleep(100);
12
13// Make sure that the service description for this service is available
14// This allows to access the service values by name (access by index
15// is always possible)
16while (!w.get().obj)
17 v8.sleep(100);
18
19console.out("have data");
20
21
22console.out("double subscription");
23var ww = new Subscription("MAGIC_WEATHER/DATA");
24
25console.out("closing 1st subscription.");
26
27var rc = w.close();
28
29console.out(" closing worked? "+rc);
30console.out("is 2nd subscription still open? "+ww.isOpen());
31
32if (ww.isOpen())
33{
34 console.out("was still open?! ... closing it ...");
35 ww.close();
36}
37else
38{
39 console.out("what if we close an already closed subscription?");
40 ww.close();
41}
42
Note: See TracBrowser for help on using the repository browser.