0

How can I deliver some data to server side while subscribing to server?

As an example,

When I subscribing /alert/12345, I want to send some other information such as alert_type, date_time etc to CometD server.

pasanbsb
  • 445
  • 2
  • 4
  • 13

1 Answers1

2

You can pass a data map in subscribe:

cometd.subscribe(channelId, undefined, callback, { data: data })

But as far as I could see, you can only get a reference to the data map in org.cometd.bayeux.server.Authorizer. I couldn't get it via org.cometd.bayeux.server.BayeuxServer.SubscriptionListener because there is no reference to the ServerMessage.

You can see my use of it here:

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • I filed http://bugs.cometd.org/browse/COMETD-504 to track this issue: `SubscriptionListener`s should be able to access the subscription message. – sbordet Feb 11 '14 at 14:42
  • I only found this data map by looking at the javascript sources. It's probably a good idea to include a section in the docs for the data map. – lance-java Feb 11 '14 at 14:53
  • Lance Java, sure. Why don't you file an issue about this at http://bugs.cometd.org ? You seem to know CometD well, so contributing back to the project in form of issue submission (http://docs.cometd.org/reference/contribute.html) will be great on the open source side of things :) Thanks ! – sbordet Feb 11 '14 at 21:02