Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#4869 closed defect (fixed)

[cometd][patch][ccla] Clean up subscribe/unsubscribe logic

Reported by: brendonh Owned by: alex
Priority: high Milestone: 1.0
Component: Dojox Version: 0.9
Keywords: Cc:
Blocked By: Blocking:


When cometd.subscribe is called, it hooks up the subscription via dojo.subscribe, putting the resulting handle in this.topics[tname]. Later, when cometd.unsubscribe is called, dojo.unsubscribe is called on that handle.

However, if you subscribe to the same channel twice without unsubscribing, the first handle is lost. The subscription remains, and now you get two dojo messages for every cometd message on that channel.

Meanwhile, cometd.unsubscribe takes objOrFunc and funcName arguments, and then does nothing with them. But if you don't provide objOrFunc, dojo.unsubscribe is never called (even though a Bayeux unsubscribe message is sent). This creates the same mess as above.

This patch:

  • Removes the existing dojo subscription (if it exists) before creating a new one
  • Removes objOrFunc and funcName from cometd.unsubscribe's parameter list (they did nothing)
  • Always removes dojo subscriptions in cometd.unsubscribe (if one exists)
  • Fixes some wrong comments where people (including me!) had copied and pasted code from cometd.subscribe to cometd.unsubscribe
  • Removes some miscellaneous extra whitespace in various places, because my emacs setup is too clever for its own good.



Attachments (1)

patch.txt (3.8 KB) - added by brendonh 14 years ago.

Download all attachments as: .zip

Change History (2)

Changed 14 years ago by brendonh

Attachment: patch.txt added

comment:1 Changed 14 years ago by alex

Resolution: fixed
Status: newclosed

(In [11119]) merging patch for subscribe/unsubscribe cleanup from Brendon. Fixes #4869

Note: See TracTickets for help on using tickets.