back_recharge
parent
2f2d597546
commit
b156df6fb0
|
@ -19,6 +19,7 @@ public class GetChatMessageHandler extends BaseHandler{
|
|||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
ChatProto.GetChatMessageInfoRequest getChatMessageInfoRequest = ChatProto.GetChatMessageInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
int chatType = getChatMessageInfoRequest.getChatType();
|
||||
ChatLogic.getInstance().getAllChatMessageInfo(iSession,chatType);
|
||||
int messageId = getChatMessageInfoRequest.getMessageId();
|
||||
ChatLogic.getInstance().getAllChatMessageInfo(iSession,chatType,messageId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ 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.globals.Global;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.dao.FriendManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
|
@ -35,20 +34,20 @@ public class ChatLogic {
|
|||
* 获取聊天信息
|
||||
* @param chatType
|
||||
*/
|
||||
public void getAllChatMessageInfo(ISession iSession, int chatType) throws Exception {
|
||||
public void getAllChatMessageInfo(ISession iSession, int chatType,int messageId) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
FriendManager friendManager = UserManager.getUser(uid).getFriendManager();
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
List<ChatProto.ChatInfo> chatInfoList = new ArrayList<>();
|
||||
switch (chatType){
|
||||
case 0: // 系统
|
||||
chatInfoList = MessageCache.sysMsg.getObjs(0);
|
||||
chatInfoList = MessageCache.sysMsg.getObjs(messageId);
|
||||
break;
|
||||
case 1: //世界
|
||||
chatInfoList = MessageCache.worldMsg.getObjs(0);
|
||||
chatInfoList = MessageCache.worldMsg.getObjs(messageId);
|
||||
break;
|
||||
case 2: //公会
|
||||
chatInfoList = MessageCache.guildMsg.getObjs(0);
|
||||
chatInfoList = MessageCache.guildMsg.getObjs(messageId);
|
||||
break;
|
||||
case 3: //好友
|
||||
Map<Object, Object> hmget = RedisUtil.getInstence().hmget(GameApplication.serverId + RedisKey.CUser_Chat + uid);
|
||||
|
@ -62,7 +61,7 @@ public class ChatLogic {
|
|||
}
|
||||
long time = Long.parseLong(split[1]);
|
||||
User user = UserManager.getUser(userid);
|
||||
chatInfoList.add(CBean2Proto.getChatInfoBuilder(user,message,time));
|
||||
chatInfoList.add(CBean2Proto.getChatInfoBuilder(user, message,time,0));
|
||||
}
|
||||
}
|
||||
if (hmget!= null && hmget.size() != 0){
|
||||
|
@ -91,23 +90,25 @@ public class ChatLogic {
|
|||
long nowTime = System.currentTimeMillis();
|
||||
switch (chatType){
|
||||
case 1: //世界
|
||||
ChatProto.ChatInfo chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime);
|
||||
MessageCache.addWordMsg(chatInfo);
|
||||
long messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_WORD_MSG_ID + GameApplication.serverId);
|
||||
ChatProto.ChatInfo chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,messageId);
|
||||
MessageCache.addWordMsg(chatInfo,messageId);
|
||||
break;
|
||||
case 2: //公会
|
||||
chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime);
|
||||
MessageCache.addGuildMsg(chatInfo);
|
||||
messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_GUILD_MSG_ID+ GameApplication.serverId);
|
||||
chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,messageId);
|
||||
MessageCache.addGuildMsg(chatInfo,messageId);
|
||||
break;
|
||||
case 3: //好友
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
if (!friends.contains(friendId)){
|
||||
MessageUtil.sendErrorResponse(iSession,0, msgId, "不能查找自己");
|
||||
MessageUtil.sendErrorResponse(iSession,0, msgId, "");
|
||||
return;
|
||||
}
|
||||
//现在好友推送
|
||||
if (OnlineUserManager.checkUidOnline(friendId)){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(friendId);
|
||||
chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime);
|
||||
chatInfo = CBean2Proto.getChatInfoBuilder(user,message,nowTime,0);
|
||||
ChatProto.SendChatInfoIndication sendChatInfoIndication = ChatProto.SendChatInfoIndication.newBuilder()
|
||||
.setChatInfo(chatInfo)
|
||||
.build();
|
||||
|
@ -126,7 +127,8 @@ public class ChatLogic {
|
|||
* 系统消息跑马灯
|
||||
*/
|
||||
public void sendSysChatMessage(String message,int messageType ,int itemId, int type,int startTime, int endTime, int priorityLevel, int frequency) {
|
||||
ChatProto.ChatInfo chatInfo = CBean2Proto.getSysChatInfoBuilder(message,messageType,itemId ,type,startTime,endTime,priorityLevel,frequency);
|
||||
MessageCache.addSystemMsg(chatInfo);
|
||||
long messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_SYS_MSG_ID+ GameApplication.serverId);
|
||||
ChatProto.ChatInfo chatInfo = CBean2Proto.getSysChatInfoBuilder(message,messageType,itemId ,type,startTime,endTime,priorityLevel,frequency,messageId);
|
||||
MessageCache.addSystemMsg(chatInfo,messageId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,18 +15,15 @@ public class MessageCache {
|
|||
public static LoopQueue guildMsg = new LoopQueue(capuatiy,perCaught,msgInterval);
|
||||
|
||||
|
||||
public static void addWordMsg(ChatProto.ChatInfo chatInfo){
|
||||
long messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_WORD_MSG_ID + GameApplication.serverId);
|
||||
public static void addWordMsg(ChatProto.ChatInfo chatInfo,long messageId){
|
||||
worldMsg.push(chatInfo,messageId);
|
||||
}
|
||||
|
||||
public static void addSystemMsg(ChatProto.ChatInfo chatInfo){
|
||||
long messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_SYS_MSG_ID+ GameApplication.serverId);
|
||||
public static void addSystemMsg(ChatProto.ChatInfo chatInfo,long messageId ){
|
||||
sysMsg.push(chatInfo,messageId);
|
||||
}
|
||||
|
||||
public static void addGuildMsg(ChatProto.ChatInfo chatInfo){
|
||||
long messageId = RedisUtil.getInstence().increment(GameApplication.serverId + RedisKey.CHAT_GUILD_MSG_ID+ GameApplication.serverId);
|
||||
public static void addGuildMsg(ChatProto.ChatInfo chatInfo,long messageId ){
|
||||
guildMsg.push(chatInfo,messageId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ public class CBean2Proto {
|
|||
}
|
||||
|
||||
|
||||
public static ChatProto.ChatInfo getChatInfoBuilder(User user,String message,long time) {
|
||||
public static ChatProto.ChatInfo getChatInfoBuilder(User user,String message,long time,long messageId) {
|
||||
ChatProto.ChatInfo.Builder chatInfo = ChatProto.ChatInfo.newBuilder();
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
chatInfo.setSenderId(user.getId());
|
||||
|
@ -234,12 +234,14 @@ public class CBean2Proto {
|
|||
chatInfo.setHead(playerInfoManager.getHead());
|
||||
chatInfo.setFrame(playerInfoManager.getFamilyId());
|
||||
chatInfo.setSoulVal(playerInfoManager.getMaxForce());
|
||||
chatInfo.setMessageId(messageId);
|
||||
return chatInfo.build();
|
||||
}
|
||||
|
||||
public static ChatProto.ChatInfo getSysChatInfoBuilder(String message,int messageType,int itemId,int type,int startTime, int endTime, int priorityLevel, int frequency) {
|
||||
public static ChatProto.ChatInfo getSysChatInfoBuilder(String message,int messageType,int itemId,int type,int startTime, int endTime, int priorityLevel, int frequency,long messageId) {
|
||||
ChatProto.ChatInfo.Builder chatInfo = ChatProto.ChatInfo.newBuilder();
|
||||
chatInfo.setItemId(itemId);
|
||||
chatInfo.setMessageId(messageId);
|
||||
chatInfo.setTimes(System.currentTimeMillis());
|
||||
chatInfo.setMsg(message);
|
||||
chatInfo.setType(type);
|
||||
|
|
Loading…
Reference in New Issue