It has been way too long since I did a “Ask a Jedi” post! This was a simple question, but I thought it might be interesting to others considering WebSockets and ColdFusion 10. Matthew asked:
As far as I know, there is no way to do this. Since subchannels are ad hoc, there seems to be no way to enumerate them.
Now - I’d say in a ‘proper’ app you know what subchannels you support anyway. My example where I allow for folks to pick from a variety of channels was hard coded, but it would have probably been database driven. If you do allow for dynamic ones, you could use a CFC call to ‘record’ it in a shared scope. Remember that you can easily run CFCs via typical AJAX calls or using the invoke API in your WebSocket object.
Of course, anyone can pop into console and subscribe to a random subchannel, but you could use a CFC handler to block that if you truly cared. Again, given that you would probably have your list database driven, it would be possible to block a subscription to an unknown subchannel. When you subscribe to x.y, where X is the known channel and Y is the subchannel, the allowSubscribe handler will see x.y. You would “pop off” the subchannel using string functions and then do your verification there.
If any of the above doesn’t make sense, let me know and I can whip up a demo.