我刚刚使用cfwebsockets开始了一个项目。当我尝试订阅我在应用程序文件<cfset this.wschannels = [{name="notify"}]>
中设置的频道时,我在chrome中得到以下响应:
Object {clientid: 540872586, ns: "coldfusion.websocket.channels", reqType: "subscribe", code: -1, type: "response"…}
clientid: 540872586
code: -1
msg: "Channel 'notify' doesn't exist or is not running."
ns: "coldfusion.websocket.channels"
reqType: "subscribe"
type: "response"
__proto__: Object
为什么不找到它?这是我的更多代码供参考。
<cfwebsocket name="notify" onOpen="subscribeUser" onMessage="msgHandler" onError="errHandler">
<script>
function errHandler(err){
console.log(err);
}
function msgHandler(message){
var data = message.data;
if(data){
}
}
function subscribeUser(){
console.log(notify);
notify.subscribe("notify",{name: '#Session.Auth.FirstName#',UserID: '#Session.Auth.UserID#',LocationID: '#Session.Auth.LocationID#'});
}
function publish(txt, msgType){
var msg = {message: txt, UserID: '#Session.Auth.UserID#', type: msgType};
var headers = {selector: 'LocationID eq "#Session.Auth.LocationID#"'};
notify.publish('notify',msg, headers);
}
</script>