0

我刚刚使用 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>
4

0 回答 0