小编Ang*_*ott的帖子

如何使用 websockets 制作 crud 应用程序?

我想用 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 发送所有信息。

websocket node.js express socket.io

3
推荐指数
1
解决办法
2398
查看次数

标签 统计

express ×1

node.js ×1

socket.io ×1

websocket ×1