2017-04-04 25 views
0

當我sailsjs 記錄創建後嘗試publishCreate我收到此錯誤錯誤:「this.adapter.clients」使用sailsjs時publishCreate

TypeError: this.adapter.clients is not a function 
at Namespace.clients (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/node_modules/sails-hook-sockets/node_modules/socket.io/lib/namespace.js:253:16) 
at Object.addRoomMembersToRooms (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/node_modules/sails-hook-sockets/lib/sails.sockets/add-room-members-to-rooms.js:50:42) 
at introduce (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/lib/hooks/pubsub/index.js:1342:23) 
at wrapper [as introduce] (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/node_modules/lodash/index.js:3095:19) 
at publishCreateSingle (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/lib/hooks/pubsub/index.js:1237:16) 
at /Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/lib/hooks/pubsub/index.js:1069:16 
at arrayEach (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/node_modules/lodash/index.js:1289:13) 
at Function.<anonymous> (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/node_modules/lodash/index.js:3345:13) 
at publishCreate (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/lib/hooks/pubsub/index.js:1068:11) 
at wrapper [as publishCreate] (/Users/oteng/.nvm/versions/node/v4.6.0/lib/node_modules/sails/node_modules/lodash/index.js:3095:19) 

這是創建函數

Tbl_Direct_Cash.create({ 
      amount_paid: amount_paid, 
      payment_type: payment_type, 
      payment_ID: payment_ID, 
      tbl_user: tbl_user 
     }).exec(function (e, r) { 
      if (e) { 
       console.log(e); 
       return res.ok('TRANSACTION FAILED....TRY AGAIN'); 
      } else { 

       //console.log(e); 
       Tbl_Direct_Cash.publishCreate({id: 40}); 
       return res.ok('TRANSACTION SAVED'); 

      } 
     }); 

,這是我的手錶方法

notify: function (req, res) { 
    if (req.isSocket) { 
     Tbl_Direct_Cash.watch(req); 
     Tbl_Deduction.watch(req); 
     // Gene.watch(req); 
     return res.ok() 
    } 
} 

創建請求被從移動發應用田地的通知要求

io.socket.on('connect', function() { 
    io.socket.get('/dashboard/notify', function (e, r) { 
     console.log(e, r); 
    }); 
}) 

從管理客戶機

+0

您使用的是什麼版本的Sails?你是使用內置的內存適配器套接字,還是'socket.io-redis'? – sgress454

+0

我們使用的是sails版本:0.12.7和'socket.io-redis' – spirit

+0

什麼版本的socket.io-redis? – sgress454

回答

0

我socket.io,Redis的版本是很老派。更新到最新版本解決了問題