mirror of
https://github.com/tl-open-source/tl-rtc-file.git
synced 2025-10-10 01:40:20 +08:00

feat: 支持敏感词检测 feat: 支持多语言版本 feat: 支持回车发送消息 feat: 支持展示房主,语言版本 feat: 支持分享链接带上语言版本 feat: 支持设置公共聊天频道消息展示条数 feat: 支持固定/临时turn账号切换 feat: 支持一键启动脚本 feat: 支持浏览器控制台打印logo feat: 调整优化svg, icon图标 feat: 调整优化弹窗动画 feat: 调整优化媒体流时间动画 feat: 调整优化oss逻辑 feat: 调整优化报错告警信息
93 lines
2.8 KiB
JavaScript
93 lines
2.8 KiB
JavaScript
const daoDog = require("./../../dao/dog/dog")
|
|
const bussinessNotify = require("../../bussiness/notify/notifyHandler")
|
|
const rtcCommData = require("../rtcCommData/commData");
|
|
const utils = require("../../utils/utils");
|
|
const rtcConstant = require("../rtcConstant");
|
|
const rtcClientEvent = rtcConstant.rtcClientEvent
|
|
const check = require("../../utils/check/content");
|
|
/**
|
|
* 公共聊天频道
|
|
* @param {*} io socketio对象
|
|
* @param {*} socket 单个socket连接
|
|
* @param {*} tables 数据表对象
|
|
* @param {*} dbClient sequelize-orm对象
|
|
* @param {*} data event参数
|
|
* @returns
|
|
*/
|
|
async function chatingComm(io, socket, tables, dbClient, data){
|
|
try {
|
|
data.msg = check.contentFilter(data.msg);
|
|
|
|
let cacheSwitchData = rtcCommData.getCacheSwitchData()
|
|
let chatingComm = rtcCommData.getChatingComm()
|
|
|
|
if(!cacheSwitchData.openCommRoom){
|
|
socket.emit(rtcClientEvent.tips, {
|
|
room: data.room,
|
|
to: socket.id,
|
|
msg: "当前功能已暂时关闭,有问题可以加群交流"
|
|
});
|
|
return
|
|
}
|
|
|
|
data.time = new Date().toLocaleString()
|
|
|
|
if (chatingComm.length < (cacheSwitchData.chatingCommCount || 10)) {
|
|
chatingComm.push(data)
|
|
} else {
|
|
chatingComm.shift()
|
|
chatingComm.push(data)
|
|
}
|
|
rtcCommData.setChatingComm(chatingComm);
|
|
|
|
io.sockets.emit(rtcClientEvent.chatingComm, data);
|
|
|
|
let {handshake, userAgent, ip} = utils.getSocketClientInfo(socket);
|
|
|
|
let recoderId = await daoDog.addDogData({
|
|
name: "公共聊天室",
|
|
roomId: data.room,
|
|
socketId: data.socketId,
|
|
device: userAgent,
|
|
flag: 0,
|
|
content: utils.unescapeStr(data.msg),
|
|
handshake: JSON.stringify(handshake),
|
|
ip: ip
|
|
}, tables, dbClient);
|
|
|
|
bussinessNotify.sendChatingNotify({
|
|
title: "公共聊天室",
|
|
room: data.room,
|
|
recoderId: recoderId,
|
|
msgRecoderId: recoderId,
|
|
socketId: data.socketId,
|
|
msg: utils.unescapeStr(data.msg),
|
|
userAgent: userAgent,
|
|
ip: ip
|
|
})
|
|
} catch (e) {
|
|
utils.tlConsole(e)
|
|
socket.emit(rtcClientEvent.tips, {
|
|
room: data.room,
|
|
to: socket.id,
|
|
msg: "系统错误"
|
|
});
|
|
bussinessNotify.sendSystemErrorMsg({
|
|
title: "socket-chatingComm",
|
|
data: JSON.stringify(data),
|
|
room: data.room,
|
|
from : socket.id,
|
|
msg : JSON.stringify({
|
|
message: e.message,
|
|
fileName: e.fileName,
|
|
lineNumber: e.lineNumber,
|
|
stack: e.stack,
|
|
name: e.name
|
|
}, null, '\t')
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
chatingComm
|
|
} |