Here is the Javascript I am using to subscribe and publish where ws is the ColdFusion WebSocket object created with the cfwebsocket tag:
ws.subscribe("messaging.friends", {userid: $('#userid').val(), selector: "targetuser eq '"+userselector+"'"}, friendsCallback);
...
ws.publish("messaging.friends", $("#message").val(), {targetuser: $('#userid').val()});
The simple code above subscribes to the messaging.friends subchannel using a selector that jQuery grabs from a web form. The second line of code published a message to that channel with the same targetuser to match the selection criteria.When I tested filtering I found that all of my messages were being delivered regardless of filtering criteria. I had read previously that if your channel listener CFC implemented the canSendMessage() method, that this would occur. I had removed the offending function but all of my messages continued to arrive regardless of selector criteria.
After much frustration I restarted ColdFusion and everything started working. What seems to have happened is that when CF the Java creates classes from your CFC it picks up on changes within a method, but does not pick up that a method has been removed until the server is restarted (or if the application ends would be my guess). Hope this saves someone some time.
You don't have to restart CF, just the App itself. Remember CF10 added an applicationStop method to make that easier.
ReplyDeleteThanks for the confirmation Ray. I don't think I've ever used applicationStop(), will have to work that into my reinitialization routine.
ReplyDeleteActually, applicationstop() was introduced in CF9.
ReplyDelete