Search code examples
javacometserver-pushcometdcometserver

deliver data to cometd server using a channel


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.


Solution

  • 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: