1 'use strict'; 2 3 // Subscribe to the the services (returns a handle to each of them) 4 var w = new Subscription("MAGIC_WEATHER/DATA"); 5 6 // Name which corresponds to handle 7 console.out(w.name); 8 9 // Wait until a valid service object is in the internal buffer 10 while (!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) 16 while (!w.get().obj) 17 v8.sleep(100); 18 19 console.out("have data"); 20 21 22 console.out("double subscription"); 23 var ww = new Subscription("MAGIC_WEATHER/DATA"); 24 25 console.out("closing 1st subscription."); 26 27 var rc = w.close(); 28 29 console.out(" closing worked? "+rc); 30 console.out("is 2nd subscription still open? "+ww.isOpen()); 31 32 if (ww.isOpen()) 33 { 34 console.out("was still open?! ... closing it ..."); 35 ww.close(); 36 } 37 else 38 { 39 console.out("what if we close an already closed subscription?"); 40 ww.close(); 41 } 42 43