#3895 closed defect (fixed)
Cometd: Mutliple callbacks on handler if a user subscribe-unsubscribe-subscribe to a channel.
Reported by: | guest | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | 1.2 |
Component: | Dojox | Version: | 0.9 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
If a user subscribes to a channel then unsubscribes and subscribes again, there will be 2 callbacks on the handler when a message is published.
var handler = {
receive: function(obj) {
console.debug("NEW MESSAGE: ", obj.data.message); alert("new message: " + obj.data.message);
}
}
function init() {
dojox.cometd.init(new String(document.location).replace(/http://[^/]*/,'')+"cometd");
}
function subscribe() {
dojox.cometd.subscribe("/messages", handler, "receive");
}
function unsubscribe() {
dojox.cometd.unsubscribe("/messages", handler, "receive");
}
function disconnect() {
dojox.cometd.disconnect();
}
function publish(id) {
dojox.cometd.publish("/messages", {message: document.getElementById(id).value});
}
To reproduce:
init(); subscribe(); publish('test1'); unsubscribe(); subscribe(); publish('test2');
There will be 2 'test2' messages received by the handler. Depending on how many times the user subscribe-unsubscribe, that will be the number of messages(duplicate) that will be received.
Attachments (1)
Change History (8)
comment:1 Changed 13 years ago by
Summary: | Mutliple callbacks on handler if a user subscribe-unsubscribe-subscribe to a channel. → Cometd: Mutliple callbacks on handler if a user subscribe-unsubscribe-subscribe to a channel. |
---|
comment:2 Changed 13 years ago by
Milestone: | 0.9 |
---|---|
Owner: | changed from Tom Trenka to alex |
Changed 13 years ago by
Attachment: | dojox-cometd-fix.patch added |
---|
comment:3 Changed 13 years ago by
comment:4 Changed 13 years ago by
David,
could you improve this patch a little bit:
the topics map probably should be called _topics
the _subscriptions array should be removed and disconnect should iterate the through the values of the _topics map. Actually then _topics could best be called _subscriptions!
Remove the FIXME comment about not doing the unsubscribe properly as it is fixed!
comment:5 Changed 13 years ago by
Also the test in subscribe and unsubscribe for
(useLocalTopics !== true) (useLocalTopics !== false)
should be
(useLocalTopics !== true)&&(useLocalTopics !== false)
comment:6 Changed 13 years ago by
Milestone: | → 1.2 |
---|---|
Priority: | high → normal |
comment:7 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | new → closed |
This appears to have been fixed with work Greg did a while back, closing as fixed.
dojox.cometd fix patch