From 730bafb538109e61aba68c15151fd02698df5c28 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Mon, 23 Sep 2019 18:02:39 +0800 Subject: [PATCH] chat --- .../ljsd/jieling/chat/logic/ChatLogic.java | 20 ++++++++++++------- .../jieling/chat/messge/MessageCache.java | 4 ---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java index 978c406c4..c35a14531 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/chat/logic/ChatLogic.java @@ -11,9 +11,11 @@ import com.ljsd.jieling.db.redis.RedisKey; import com.ljsd.jieling.db.redis.RedisUtil; import com.ljsd.jieling.logic.OnlineUserManager; import com.ljsd.jieling.logic.dao.FriendManager; +import com.ljsd.jieling.logic.dao.GuilidManager; import com.ljsd.jieling.logic.dao.PlayerManager; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.family.GuildLogic; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.protocols.ChatProto; import com.ljsd.jieling.protocols.MessageTypeProto; @@ -53,9 +55,6 @@ public class ChatLogic { case 1: //世界 chatInfoList = MessageCache.worldMsg.getObjs(messageId); break; - case 2: //公会 - chatInfoList = MessageCache.guildMsg.getObjs(messageId); - break; case 3: //好友 Map hmget = RedisUtil.getInstence().hmget(GameApplication.serverId + RedisKey.CUser_Chat + uid); if (hmget != null && hmget.size() != 0){ @@ -142,9 +141,16 @@ public class ChatLogic { MessageCache.addWordMsg(chatInfo,messageId); break; case 2: //公会 - messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_GUILD_MSG_ID+ GameApplication.serverId); - chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,messageId); - MessageCache.addGuildMsg(chatInfo,messageId); + int guildId = user.getPlayerInfoManager().getGuildId(); + if(guildId==0){ + MessageUtil.sendErrorResponse(iSession,0, msgId, "未加入公会"); + return; + } + chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,0); + ChatProto.SendChatInfoIndication sendChatInfoIndication = ChatProto.SendChatInfoIndication.newBuilder() + .setChatInfo(chatInfo) + .build(); + GuildLogic.sendIndicationToMember(GuilidManager.guildInfoMap.get(guildId),MessageTypeProto.MessageType.SEND_CHAT_INFO_INDICATION,sendChatInfoIndication); break; case 3: //好友 List friends = friendManager.getFriends(); @@ -156,7 +162,7 @@ public class ChatLogic { if (OnlineUserManager.checkUidOnline(friendId)){ ISession sessionByUid = OnlineUserManager.getSessionByUid(friendId); chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,0); - ChatProto.SendChatInfoIndication sendChatInfoIndication = ChatProto.SendChatInfoIndication.newBuilder() + sendChatInfoIndication = ChatProto.SendChatInfoIndication.newBuilder() .setChatInfo(chatInfo) .build(); assert sessionByUid != null; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java b/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java index 54afc6926..44e4e086f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/chat/messge/MessageCache.java @@ -9,7 +9,6 @@ public class MessageCache { public static LoopQueue worldMsg = new LoopQueue(capuatiy,perCaught,msgInterval); public static LoopQueue sysMsg = new LoopQueue(capuatiy,perCaught,msgInterval); - public static LoopQueue guildMsg = new LoopQueue(capuatiy,perCaught,msgInterval); public static void addWordMsg(ChatProto.ChatInfo chatInfo,long messageId){ @@ -20,7 +19,4 @@ public class MessageCache { sysMsg.push(chatInfo,messageId); } - public static void addGuildMsg(ChatProto.ChatInfo chatInfo,long messageId ){ - guildMsg.push(chatInfo,messageId); - } }