代码拉取完成,页面将自动刷新
//see https://github.com/facundoolano/socketio-auth
/**
*
*
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
socket.broadcast.to('game').emit('message', 'nice game');
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
// sending to all clients in 'game' room(channel), include sender
io.sockets.in('game').emit('message', 'cool game');
// sending to individual socketid
io.sockets.socket(socketid).emit('message', 'for your eyes only');
socket.leave(data.room);
*/
import SocketIO from 'socket.io';
import fs from 'fs-extra';
module.exports = app => {
let io = new SocketIO(app.server);
io.on('connection', async (socket) => {
console.log("on connection, socket id is ", socket.id)
socket.on('disconnect', () => {
});
socket.on('leave', (msg) => {
});
socket.on('m:msg', async(msg) => {
console.log("message is coming, the content is "+msg)
});
socket.on('m:delete_voice', async(filepath) => {
console.log("delete file commond is comming "+filepath)
if(fs.existsSync(filepath)){
setTimeout(() => {
fs.removeSync(filepath);
console.log("delete file commond is deleted: "+filepath)
}, 10000);
}
});
// socket.on('m:play_finished', async(filepath) => {
// global.is_playing = false;
// });
});
return io;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。