/**
 * socket入口脚本文件
 *
 * @author caiaolin
 * @date 2017-05-12
 * @version
 */
import socket from "socket.io";

const socketIO = socket(3300);

// socket.io相关操作
socketIO.on('connection', function(socket) {
    let roomId = '';
    console.log("new connection");
    // 加入房间
    socket.on('join', function(data) {
        roomId = data;
        socket.join(data);
    });


    // 数据更改通知
    socket.on('dataNotify', function(data) {
        socket.broadcast.to(roomId).emit('dataChange', data);
    });
    socket.on('feeRateChangeNotify', function(data) {
        socket.broadcast.to(data).emit('feeRateChange', data);
    });
    socket.on('changeActivateFeeRate', function(data) {
        socket.leave(data.oldRoom);
        socket.join(data.newRoom);
    });

});
