Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何向特定客户端发送消息,更具体地说,是刚刚连接到应用程序的客户端,而不向已经在网站上的其他访问者广播?
io.sockets.on('connection', function(client) { });
似乎每次有新访客连接时都会向所有人广播。
var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket) { socket.emit('greetings', { greeting:'hello, new visitor' }); socket.on('greetingFromVisitor', function (data) { console.log(data); }); });