riccardocagnasso

NAV javascript library

Jun 11th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class NAV {
  2.     constructor(name, url="ws://localhost:8080/ws", realm="realm1"){
  3.         this.name = name;
  4.         this.url = url;
  5.         this.realm = realm;
  6.  
  7.         this.connection = new autobahn.Connection({
  8.            url: this.url,
  9.            realm: this.realm
  10.         });
  11.  
  12.         this.connection.onopen = (session => this.on_open(session))
  13.         this.connection.open()
  14.     }
  15.  
  16.     on_open(session){
  17.         this.session = session;
  18.         this.session.subscribe('org.nav.modules.' + this.name, this.on_message);
  19.         console.log('org.nav.modules.' + this.name)
  20.         this.session.publish('org.nav.announce', [this.name]);
  21.     }
  22.  
  23.     on_message(message){
  24.         console.log("THIS ON MESSAGE")
  25.         console.log(message);
  26.     }
  27.  
  28.     send_command(target, subject, payload){
  29.  
  30.     }
  31. }
  32.  
  33. var nav = new NAV('test_module');
Advertisement
Add Comment
Please, Sign In to add comment