Javascript Sails JS发布更新不工作

Javascript Sails JS发布更新不工作,javascript,node.js,sails.js,Javascript,Node.js,Sails.js,使用sails js和twilio节点编写一个简单的呼叫跟踪器,但是publishUpdate似乎并没有向我的前端客户端发送消息。Model.publish正在工作,但Model.publishUpdate不工作。我是否做了任何明显错误的事情,或者有什么我错了 这是我的密码。 在我的主控制器中,我有一个特定的路由将客户机订阅到我的模型 在MainController.js中 calls: function(req,res){ Calls.find(function fou

使用sails js和twilio节点编写一个简单的呼叫跟踪器,但是publishUpdate似乎并没有向我的前端客户端发送消息。Model.publish正在工作,但Model.publishUpdate不工作。我是否做了任何明显错误的事情,或者有什么我错了

这是我的密码。 在我的主控制器中,我有一个特定的路由将客户机订阅到我的模型

在MainController.js中

calls: function(req,res){
            Calls.find(function foundCalls(err, calls) {
                    if (err) return next(err);

                    // subscribe this socket to the Calls classroom
                    Calls.subscribe(req.socket);

                    // subscribe this socket to the Calls instance rooms
                    Calls.subscribe(req.socket, calls);

                    // This will avoid a warning from the socket for trying to render
                    // html over the socket.
                    res.send(calls,200);
            });
    },
   takecall: function(req,res) {

      Calls.findOneByCallSid(req.body.CallSid).done(function(err, thiscall) {
                    if(err){
                            return next(err);

                   } else {
                            // 1a. Save additional parameters
                            thiscall.DialCallDuration=req.body.DialCallDuration
                            thiscall.DialCallSid=req.body.DialCallSid
                            thiscall.RecordingUrl=req.body.RecordingUrl
                            thiscall.DialCallStatus=req.body.DialCallStatus
                            thiscall.RecordingDuration=req.body.RecordingDuration
                            thiscall.RecordingSid=req.body.RecordingSid
                            thiscall.save(function(err,call) {
                                    if (err) return next(err);
                                    console.log(call.id);
                                    Calls.publishUpdate(call.id,{message:'hello'});
                            });

                            // 3. Display twiml that tells twilio we are done with call workflow
                            var twilio = require('twilio');
                            var resp = new twilio.TwimlResponse();
                            res.send(resp.toString(), 200);
                    }
            });



    }
在我的app.js文件中

socket.on('connect', function socketConnected() {

    socket.get('/main/calls', function(response){console.log(response)});


    socket.on('message', function(message) {
            console.log(message);
    });
});
在另一个控制器中,我有: CallController.js

calls: function(req,res){
            Calls.find(function foundCalls(err, calls) {
                    if (err) return next(err);

                    // subscribe this socket to the Calls classroom
                    Calls.subscribe(req.socket);

                    // subscribe this socket to the Calls instance rooms
                    Calls.subscribe(req.socket, calls);

                    // This will avoid a warning from the socket for trying to render
                    // html over the socket.
                    res.send(calls,200);
            });
    },
   takecall: function(req,res) {

      Calls.findOneByCallSid(req.body.CallSid).done(function(err, thiscall) {
                    if(err){
                            return next(err);

                   } else {
                            // 1a. Save additional parameters
                            thiscall.DialCallDuration=req.body.DialCallDuration
                            thiscall.DialCallSid=req.body.DialCallSid
                            thiscall.RecordingUrl=req.body.RecordingUrl
                            thiscall.DialCallStatus=req.body.DialCallStatus
                            thiscall.RecordingDuration=req.body.RecordingDuration
                            thiscall.RecordingSid=req.body.RecordingSid
                            thiscall.save(function(err,call) {
                                    if (err) return next(err);
                                    console.log(call.id);
                                    Calls.publishUpdate(call.id,{message:'hello'});
                            });

                            // 3. Display twiml that tells twilio we are done with call workflow
                            var twilio = require('twilio');
                            var resp = new twilio.TwimlResponse();
                            res.send(resp.toString(), 200);
                    }
            });



    }

你在运行什么版本的帆?