Ticket #5963 (assigned defect)

Opened 4 months ago

Last modified 4 weeks ago

Comet - subscribing to a glob channel

Reported by: guest Owned by: alex
Priority: normal Milestone: 1.2
Component: Dojox Version: 1.0
Severity: normal Keywords: comet, glob, subscribe, channel
Cc: geoffreyj.lee@…

Description (last modified by dylan) (diff)

Subscribing to the * channels doesn't seem to work. Let's say we have the channels /foo and /bar. When the user subscribes to /*, the user does a client-side dojo.subscribe to /*, but the actual message will be published to either /foo or /bar on the client side. In other words, the server delivers the messages to the client, but the client is listening on a different Dojo channel.

I wasn't sure what to set the ticket properties to, so I'm hoping somebody else will edit them.

-Geoffrey Lee

Change History

Changed 4 months ago by alex

  • owner changed from anonymous to alex
  • status changed from new to assigned
  • milestone set to 1.2

Changed 4 months ago by dylan

  • milestone changed from 1.2 to 1.1

move back to 1.1 per request by Greg Wilkins.

Changed 4 months ago by gregwilkins

I think this is simply because dojo.subscribe does not support wild cards.

So I think that when we receive a message on channel /foo/bar/boo then we should publish it to dojo topics:

/cometd/** /cometd/foo/** /cometd/foo/bar/** /cometd/foo/bar/* /cometd/foo/bar/boo

Is that reasonable?

Changed 4 months ago by guest

Seems reasonable to me. Here's the modified code for dojox.cometd._deliver that I'm using to do this:

// dispatch the message to any locally subscribed listeners
try {
	var tname = "/cometd"+message.channel;
	dojo.publish(tname, [ message ]);
	
	// Begin changes
	var tnameParts = message.channel.split("/");
	var tnameGlob = "/cometd";
	for (var i = 1; i < tnameParts.length - 1; i++) {
		dojo.publish(tnameGlob + "/**", [ message ]);
		tnameGlob += "/" + tnameParts[i];
	}
	dojo.publish(tnameGlob + "/**", [ message ]);
	dojo.publish(tnameGlob + "/*", [ message ]);
	// End changes
}catch(e){
	console.debug(e);
}

-Geoffrey Lee

Changed 4 months ago by gregwilkins

Great!

I've committed with the slight change of publishing to the real topic after the glob topics, so that it is like we have descended the tree.

If you can test this, I will see if it can make it into 1.1

Changed 3 months ago by bill

  • component changed from General to Dojox
  • milestone changed from 1.1 to 1.2

Move all milestone 1.1 tickets to 1.2, except for reopened tickets and tickets opened after 1.1RC1 was released.

Changed 4 weeks ago by dylan

  • description modified (diff)

Marked #4961 as a duplicate of this ticket. Also, #6385 is a request to add this to dojo.publish() and dojo.subscribe().

Note: See TracTickets for help on using tickets.