This post is more than 2 years old.
What follows are two little experiments I did with ColdFusion 10 WebSockets. I'm not sure how useful these are but I thought I'd share them. As a reminder, I'll be presenting on WebSockets this weekend at NCDevCon along with many other people far more intelligent than myself. I think there is something like 2 tickets left so it's not too late!
The first thing I tested was passing a random-ish string to wsGetSubscribers. wsGetSubscribers is a server-side function that gets subscriber data about a particular WebSocket channel. It is smart enough to understand subchannels too so if you pass in channel.subchannel as an argument, it will filter correctly. My experiment was to see what would happen if I passed some nonsense value, like news.XXXXXXX. As I kinda figured, this worked fine. Clients can subscribe to any subchannel unless you explicitly block it on the subscriber handler. Therefore, wsGetSubscribers allows for anything as well.
Not very helpful I guess, but I wanted to share.
The second thing I tried was a bit more complex. I wanted to know if it was possible for the server to send a message to one user. Technically you have support for one to one communication with Point to Point WebSockets, but these calls are in response to the client sending a message. I wanted the server to be able to broadcast to one (or perhaps a few) client.
There are probably multiple ways of doing this. For example, when the client subscribes, they could subscribe to a channel called "private" and use a subchannel which includes their clientid. Or they could use a selector.
But I was curious to see if I could use one channel and get the same result. Since the server can get all the clients, I built a simple interface to get them and use the IDs in a drop down.
This form isn't very pretty, but it gets the job done. On the flip side, I used the CFC handler and the canSendMessage method to do my filtering. canSendMessage is run before the message is broadcast to each individual client.
Anyway, I hope this information is useful to people.