diff --git a/src/api_s2c/chat/ApiSend.ts b/src/api_s2c/chat/ApiSend.ts index 4d182d0..7ae9a4c 100644 --- a/src/api_s2c/chat/ApiSend.ts +++ b/src/api_s2c/chat/ApiSend.ts @@ -1,6 +1,6 @@ import { ApiCall, WsClientStatus } from "tsrpc"; import { ActionLog } from '../../public/actionLog/actionLog'; -import { ChatFun } from '../../public/chat'; +import { ChatFun, getCrossChatGroupByOpenDay } from '../../public/chat'; import { ReqSend, ResSend } from "../../shared/protocols/chat/PtlSend"; import { chatMsgLog } from "../../shared/protocols/type" import { getGud } from "../../public/gud"; @@ -40,6 +40,8 @@ export default async function (call: ApiCall) { if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) { //如果是跨服的话,调用跨服API的这条协议 + sendData.otherData.group = getCrossChatGroupByOpenDay(); + G.clientCross.sendMsg('msg_cross/CrossChat', sendData); call.succ({}); return; diff --git a/src/public/chat.ts b/src/public/chat.ts index d0e2286..877f6fd 100644 --- a/src/public/chat.ts +++ b/src/public/chat.ts @@ -3,6 +3,7 @@ import { ApiCall } from 'tsrpc'; import { MsgChat } from '../shared/protocols/msg_s2c/MsgChat'; import { player } from '../shared/protocols/user/type'; import { chatLog, chatMsgLog } from '../shared/protocols/type' +import { PublicShared } from '../shared/public/public'; const msgListLen = { 'cross': 30, @@ -10,6 +11,20 @@ const msgListLen = { 'guild': 20 }; +/** + * 通过开服天数,获取跨服聊天分组 + */ +export function getCrossChatGroupByOpenDay(){ + let openday = PublicShared.getOpenServerDay(); + if(openday<=7){ + return 1; + }else if(openday <= 30){ + return 2; + }else{ + return 3; + } +} + export class ChatFun { /**新增消息 */ static async newMsg(sendData: MsgChat) { @@ -23,7 +38,11 @@ export class ChatFun { G.server.broadcastClusterMsg('msg_s2c/Chat', sendData,{ghId:(sendData.sender as player)?.ghId}); }else if(sendData.type == 'cross'){ //所有的子进程都会收到,不需要集群内分别广播 - G.server.broadcastMsg('msg_s2c/Chat', sendData); + if(sendData?.otherData?.group == getCrossChatGroupByOpenDay()){ + //如果时候同一个分组的 + delete sendData?.otherData?.group; + G.server.broadcastMsg('msg_s2c/Chat', sendData); + } }else{ G.server.broadcastClusterMsg('msg_s2c/Chat', sendData); }