我想用 socketio 制作一个快速的应用程序,一个简单但实时的 crud 应用程序
socket.on('users:create',function(data){
console.log(data);
salt = cryptom.salt(32);
hash = cryptom.hash(data.pass,salt);
u = new user({ name: data.name,
salt: salt,
hash: hash,
email: data.email,
ci: data.ci,
telf: data.telf,
rif: data.rif,
});
u.save(function (err) {
if(err){
console.log(err);
}else{
user.find({},function(err,user){
io.sockets.emit('users:index',user);
});
}});
})
Run Code Online (Sandbox Code Playgroud)
我想知道这是否正确,是否有效通过 websockets 发送所有信息。