From ebb8c6341c19a73ed14651c2a5143fe059e570e0 Mon Sep 17 00:00:00 2001 From: gaojie Date: Tue, 11 Jun 2019 18:02:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E8=81=8A=E5=A4=A9=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E5=A5=BD=E5=8F=8B=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/chat/logic/ChatLogic.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 1b3f83e63..5e9078e53 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 @@ -5,6 +5,7 @@ import com.ljsd.GameApplication; import com.ljsd.jieling.chat.messge.MessageCache; 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.UserManager; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.network.session.ISession; @@ -57,6 +58,8 @@ public class ChatLogic { CBean2Proto.getChatInfoBuilder(user,message,time); } } + //取出数据好友聊天数据后删除 + RedisUtil.getInstence().hdel(GameApplication.serverId + RedisKey.CUser_Chat + uid); break; } ChatProto.GetChatMessageInfoResponse getChatMessageInfoResponse = ChatProto.GetChatMessageInfoResponse @@ -85,7 +88,18 @@ public class ChatLogic { MessageCache.addGuildMsg(chatInfo); break; case 3: //好友 - RedisUtil.getInstence().hset(GameApplication.serverId +RedisKey.CUser_Chat+friendId,uid +"#"+ nowTime,message, -1); + //现在好友推送 + if (OnlineUserManager.checkUidOnline(friendId)){ + ISession sessionByUid = OnlineUserManager.getSessionByUid(friendId); + chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime); + ChatProto.SendChatInfoIndication sendChatInfoIndication = ChatProto.SendChatInfoIndication.newBuilder() + .setChatInfo(chatInfo) + .build(); + assert sessionByUid != null; + MessageUtil.sendMessage(sessionByUid, 1, MessageTypeProto.MessageType.SEND_FRIEND_INFO_INDICATION_VALUE, sendChatInfoIndication, true); + }else{ + RedisUtil.getInstence().hset(GameApplication.serverId +RedisKey.CUser_Chat+friendId,uid +"#"+ nowTime,message, -1); + } break; } MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.SEND_CHAT_INFO_RESPONSE_VALUE, null, true);