Wednesday, 31 May 2017

Autobahn identify subscription

When creating a websockets connection how can I determine the name of the subscription in the event function.

For example if I have three subscriptions I wish to be able to identify which once triggered the event.

var autobahn = require('autobahn');

var connection = new autobahn.Connection({url: 'ws://127.0.0.1:9000/', realm: 'realm1'});

connection.onopen = function (session) {

   function onevent(args) {
      console.log("Colour is: ", ?????);
   }

   ["Red", "Green", "Brown"].forEach(function(colour) {
     session.subscribe(colour, onevent);
   }


};

connection.open();



via Dercni

No comments:

Post a Comment