Hi,
On Sat, May 18, 2013 at 10:02 PM, Santh <
suthar...@gmail.com> wrote:
> Hi Simon,
>
> Thanks for that. I can understand that. But I wanted a code sample because
> when I try in the following way, It is not working properly. I see a
> disconnection & reconnection when the second channel is added. Pls let me
> know whether this is correct implementation:
>
> function _metaHandshake(handshake) {
> if (handshake.successful === true) {
> cometd.batch(function () {
> cometd.addListener(channelName1, function (message) {
> //processResponse
> });
> cometd.publish(channelName1);
>
> cometd.addListener(channelName2, function (message) {
> //processResponse
> });
> cometd.publish(channelName2);
> });
> }
> }
Makes little sense to add listeners in a /meta/handshake function:
every time you re-handshake, you will add another listener without
removing the previous ones.
Please have a read at
http://docs.cometd.org/reference/#javascript_subscribe_vs_listen.
You say "I see a disconnection & reconnection when the second channel is added".
You need to be way more specific:
1. define "disconnection and reconnection" (at TCP level ? at Bayeux
level ? Other levels ?),
2. where do you see it (client ? server ?),
3. there is no "channel added", so I have no idea what you refer to.
You can't post a snippet of code saying that in your opinion is not
working properly, without posting the eventual error log, or at least
what behaviour you expect, and what you actually get.
This is a very similar snippet of code, and it works:
https://github.com/cometd/cometd-tutorials/blob/master/server-stock-price/src/main/webapp/application.js.
This read may help you:
http://www.catb.org/esr/faqs/smart-questions.html
CometD provides you with full fledged skeleton applications that you
can create via Maven archetypes, see
http://docs.cometd.org/reference/#primer.
CometD provides you with tutorials, see
http://docs.cometd.org/tutorials/.
Try following those, and if you still have a problem, let us know.
For example, I realize now that the documentation is lacking about how
to enable debug logging - which may help you.
I have created this bug about:
http://bugs.cometd.org/browse/COMETD-429.
Thanks !