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