Hi all,
Until a couple weeks ago I hadn't used CometD since version 2.x
Back then I had a case where I used a dequeue listener to remove messages as they were being sent to the client. It was a security requirement I had to deal with. It worked but I never felt comfortable using it.
Fast forward to today using 4.0.4.
I have a situation where I want to publish and subscribe to the same channel but I would like to prevent a client form receiving their own published messages.
I understand that this may be a bit of an anti-pattern. But it does seem like a reasonable use case.
So far, I've tired 2 things:
First, I tried using a service channel that would deliver messages to all subscribers except to the source of the message. It appears that while subscription is allowed on service channels, Cometd doesn't maintain the subscription. So I couldn't find a populated set of subscribers to iterate over. A closer reading of the docs indicated that subscribe, while allowed on service channels, is a noop on service channels. So I guess that means subscriptions aren't maintained. That made sense when I thought about it. So I moved on.
Second, I tried my hand at a server side extension. Only the outgoing and send methods have access to the from and to sessions. That seems consistent with me using deque listener for similar stuff in the past. Within this path I've tried both outgoing and send methods. Through use of logging and debugging I appear to detect the proper conditions for removal but nothing I tried actually prevented the publishing client from receiving their own messages. implementing outgoing I tried setting promise.succeed to null and false. For send I returned false. Neither worked for me. I did start pouring over the source. I'm a little lost in the foldleft loop to be honest:-)
There are more details I can share. However, is this something I should be able to do with Extensions?
I noticed the use of dequeue listeners in the unit tests so maybe I'll try that route. Using a dequeue listener makes me feel a little like I've invited myself into cometd's living room.
Any suggestions would be much appreciated.
Thanks,
Glenn