2016-12-21 53 views

回答

0

所有你需要做的就是打開配置/ bootstrap.js,並提出了以下變化有

module.exports.bootstrap = function(cb) { 

    // handle connect socket first event executes after logged in 
    sails.io.on('connect', function (socket){ 
     socket.emit("connected",{ data: "here am i!" }) 
    }); 

    // handle custom listener for other stuff 
    sails.io.on('ping', function (socket){ 
     socket.emit("pong",{ data: "send to android/ios/web client" }) 
    }); 
cb(); 
}; 

在這裏你可以監聽多個事件,以及你可以發出多個私有/廣播消息,以及和所有socket.io聽衆也會在這裏工作

相關問題