I have a crossbar.io server setup and I am trying the example code in a browser (chrome 81.x) on https://github.com/crossbario/autobahn-js
// 1) subscribe to a topic
function onevent(args) {
console.log("Event:", args[0]);
}
session.subscribe('com.myapp.hello', onevent);
// 2) publish an event
session.publish('com.myapp.hello', ['Hello, world!']);
I don't see the subscribe message. I have since developed my own application and I see the same thing. A web page that publishes the event doesn't have it's subscribe called. In other words, if I have the same page open in 2 windows and have page A publish a message, page B gets the subscribe event, but page A does not.
Not sure if this is an issue with autobahn-js or with crossbar.io.
I previously had a WAMP v1 implementation (with a custom router) that supported this. It's kind of critical for me to make sure a page sees its own publish messages. There is a lot of work for me to convert my code if this isn't possible.
Found the answer. It's in the documentation depending on which version Google finds for you.
https://github.com/crossbario/autobahn-js/blob/master/doc/programming.md
By default, a publisher will not receive an event it publishes even when the publisher is itself subscribed to the topic subscribed to. This behavior can be overridden by passing exclude_me: False in the options.
session.publish('com.myapp.complex', [1, 2, 3], {foo: "bar"}, {exclude_me: false});