使用长轮询或 WebSockets 启用实时双向基于事件的通信
    并具有断开连接检测和自动重新连接支持

    1. const server = require('http').createServer();
    2. const io = require('socket.io')(server);
    3. io.on('connection', client => {
    4. client.on('event', data => { /* … */ });
    5. client.on('disconnect', () => { /* … */ });
    6. });
    7. server.listen(3000);