📜  从 javascript 代码示例调用节点 js 函数

📅  最后修改于: 2022-03-11 15:01:58.285000             🧑  作者: Mango

代码示例2
var io = require('socket.io').listen(80); // initiate socket.io server

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' }); // Send data to client

  // wait for the event raised by the client
  socket.on('my other event', function (data) {  
    console.log(data);
  });
});