Merge branch 'master' of 60.1.1.230:backend/jieling_server
commit
aeb701dc14
|
|
@ -5,7 +5,9 @@ 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;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
|
@ -35,6 +37,8 @@ public class ChatLogic {
|
|||
*/
|
||||
public void getAllChatMessageInfo(ISession iSession, int chatType) 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: // 系统
|
||||
|
|
@ -53,14 +57,17 @@ public class ChatLogic {
|
|||
String[] split = entry.getKey().toString().split("#");
|
||||
String message = String.valueOf(entry.getValue());
|
||||
int userid = Integer.parseInt(split[0]);
|
||||
if (!friends.contains(userid)){
|
||||
continue;
|
||||
}
|
||||
long time = Long.parseLong(split[1]);
|
||||
User user = UserManager.getUser(userid);
|
||||
CBean2Proto.getChatInfoBuilder(user,message,time);
|
||||
chatInfoList.add(CBean2Proto.getChatInfoBuilder(user,message,time));
|
||||
}
|
||||
}
|
||||
if (hmget!= null && hmget.size() != 0){
|
||||
//取出数据好友聊天数据后删除
|
||||
RedisUtil.getInstence().hdel(GameApplication.serverId + RedisKey.CUser_Chat + uid);
|
||||
RedisUtil.getInstence().del(GameApplication.serverId + RedisKey.CUser_Chat + uid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -77,8 +84,10 @@ public class ChatLogic {
|
|||
* @param message
|
||||
*/
|
||||
public void sendChatMessage(ISession iSession, int chatType, String message,int friendId) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.SEND_CHAT_INFO_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
FriendManager friendManager = user.getFriendManager();
|
||||
long nowTime = System.currentTimeMillis();
|
||||
switch (chatType){
|
||||
case 1: //世界
|
||||
|
|
@ -90,6 +99,11 @@ public class ChatLogic {
|
|||
MessageCache.addGuildMsg(chatInfo);
|
||||
break;
|
||||
case 3: //好友
|
||||
List<Integer> friends = friendManager.getFriends();
|
||||
if (!friends.contains(friendId)){
|
||||
MessageUtil.sendErrorResponse(iSession,0, msgId, "不能查找自己");
|
||||
return;
|
||||
}
|
||||
//现在好友推送
|
||||
if (OnlineUserManager.checkUidOnline(friendId)){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(friendId);
|
||||
|
|
@ -98,21 +112,21 @@ public class ChatLogic {
|
|||
.setChatInfo(chatInfo)
|
||||
.build();
|
||||
assert sessionByUid != null;
|
||||
MessageUtil.sendMessage(sessionByUid, 1, MessageTypeProto.MessageType.SEND_CHAT_INFO_INDICATION_VALUE, sendChatInfoIndication, true);
|
||||
MessageUtil.sendIndicationMessage(sessionByUid, 1, MessageTypeProto.MessageType.SEND_CHAT_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);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, null, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 系统消息跑马灯
|
||||
*/
|
||||
public static void sendSysChatMessage(String message,int type,int startTime, int endTime, int priorityLevel, int frequency) {
|
||||
ChatProto.ChatInfo chatInfo = CBean2Proto.getSysChatInfoBuilder(message,type,startTime,endTime,priorityLevel,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);
|
||||
MessageCache.addSystemMsg(chatInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,6 @@ public class MapManager extends MongoBase {
|
|||
if (addValue != 0) {
|
||||
int curEnergy = MathUtils.setBetweenWithMax(itemNum + addValue, 0, SGameSetting.getGameSetting().getInitialEnergy());
|
||||
item.setItemNum(curEnergy > playerInfoManager.getMaxStamina() ? playerInfoManager.getMaxStamina() : curEnergy);
|
||||
System.out.println("增加之前的==============================="+itemNum + "增加的数量============"+addValue +"总数========="+item.getItemNum());
|
||||
setLastUpdateEnergyTime(item, updateTime, lastUpdateEnergyTime);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class FriendLogic {
|
|||
List<Integer> friends = friendManager.getFriends();
|
||||
List<Integer> onlineList = new CopyOnWriteArrayList<>();
|
||||
for (Integer friendId :friends){
|
||||
if(!OnlineUserManager.checkUidOnline(uid)){
|
||||
if(!OnlineUserManager.checkUidOnline(friendId)){
|
||||
continue;
|
||||
}
|
||||
onlineList.add(friendId);
|
||||
|
|
@ -460,13 +460,13 @@ public class FriendLogic {
|
|||
return;
|
||||
}
|
||||
if (playerInfoManager.getNickName().equals(name)){
|
||||
MessageUtil.sendErrorCode(iSession, Global.NO_FIND_ONESELF_STATE, "不能查找自己");
|
||||
MessageUtil.sendErrorResponse(iSession, Global.NO_FIND_ONESELF_STATE, msgId, "不能查找自己");
|
||||
return;
|
||||
}
|
||||
String key = RedisKey.getKey(RedisKey.C_User_Name_Key, name, false);
|
||||
Object friend = RedisUtil.getInstence().get(key);
|
||||
if (friend == null){
|
||||
MessageUtil.sendErrorCode(iSession, Global.USER_NO_EXIT_STATE, "玩家不存在");
|
||||
MessageUtil.sendErrorResponse(iSession, Global.USER_NO_EXIT_STATE, msgId, "玩家不存在");
|
||||
return;
|
||||
}
|
||||
int type = 1;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.hero;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.chat.logic.ChatLogic;
|
||||
import com.ljsd.jieling.config.*;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
|
|
@ -19,6 +20,7 @@ import com.ljsd.jieling.util.*;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.rmi.ServerError;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
|
@ -1146,6 +1148,10 @@ public class HeroLogic {
|
|||
.newBuilder()
|
||||
.setDrop(drop)
|
||||
.build();
|
||||
List<CommonProto.Hero> heroList = drop.getHeroList();
|
||||
CommonProto.Hero hero = heroList.get(0);
|
||||
int heroId = hero.getHeroId();
|
||||
ChatLogic.getInstance().sendSysChatMessage("",1,heroId,0,0,0,0,0);
|
||||
MessageUtil.sendMessage(iSession,1,msgId,heroComposeResponse,true); }
|
||||
|
||||
public void getAllPokemon(ISession iSession) throws Exception {
|
||||
|
|
|
|||
|
|
@ -236,11 +236,13 @@ public class CBean2Proto {
|
|||
return chatInfo.build();
|
||||
}
|
||||
|
||||
public static ChatProto.ChatInfo getSysChatInfoBuilder(String message,int type,int startTime, int endTime, int priorityLevel, int frequency) {
|
||||
public static ChatProto.ChatInfo getSysChatInfoBuilder(String message,int messageType,int type,int itemId,int startTime, int endTime, int priorityLevel, int frequency) {
|
||||
ChatProto.ChatInfo.Builder chatInfo = ChatProto.ChatInfo.newBuilder();
|
||||
chatInfo.setItemId(itemId);
|
||||
chatInfo.setTimes(System.currentTimeMillis());
|
||||
chatInfo.setMsg(message);
|
||||
chatInfo.setType(type);
|
||||
chatInfo.setMessageType(messageType);
|
||||
if (type == 1){
|
||||
chatInfo.setStartTime(startTime);
|
||||
chatInfo.setEndTime(endTime);
|
||||
|
|
|
|||
|
|
@ -387,6 +387,9 @@ public class ItemUtil {
|
|||
if(itemNum>=0){
|
||||
itemProtoList.add(CBean2Proto.getItem(item,itemNum));
|
||||
}
|
||||
if (entry.getKey() == Global.STAMINA){
|
||||
LOGGER.info("增加的=========num={}, 操作后={}, 时间={}",itemNum,user.getItemManager().getItemMap().get(Global.STAMINA).getItemNum(),user.getItemManager().getItemMap().get(Global.STAMINA).getEndingTime());
|
||||
}
|
||||
}
|
||||
if (dropBuilder != null) {
|
||||
dropBuilder.addAllItemlist(itemProtoList);
|
||||
|
|
@ -540,6 +543,9 @@ public class ItemUtil {
|
|||
temporaryItemList.remove(userItem.getKey());
|
||||
needCount = Math.abs(leftNum);
|
||||
}
|
||||
if (userItem.getKey() == Global.STAMINA){
|
||||
LOGGER.info("消耗的=========num={}, 操作后={}, 时间={}",needCount,user.getItemManager().getItemMap().get(Global.STAMINA).getItemNum(),user.getItemManager().getItemMap().get(Global.STAMINA).getEndingTime());
|
||||
}
|
||||
}
|
||||
Item myItem = itemManager.getItem(userItem.getKey());
|
||||
if (null == myItem) {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class MessageUtil {
|
|||
}
|
||||
GeneratedMessage generatedMessage = CommonProto.ErrorResponse.newBuilder().setErrCode(errorCode).setErrMsg(errMsg).build();
|
||||
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(),
|
||||
errorCode, MessageTypeProto.MessageType.ERROR_CODE_INDICATION_VALUE, generatedMessage);
|
||||
0, MessageTypeProto.MessageType.ERROR_CODE_INDICATION_VALUE, generatedMessage);
|
||||
session.writeAndFlush(byteBuf);
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ public class MessageUtil {
|
|||
generatedMessage = CommonProto.ErrorResponse.newBuilder().setErrCode(errorCode).setErrMsg(errMsg).build();
|
||||
LOGGER.error("send error msg,the uid={},the msgId={},the errMsg={}",session.getUid(),msgId,errMsg);
|
||||
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), session.getIndex(),
|
||||
errorCode,msgId, generatedMessage);
|
||||
0,msgId, generatedMessage);
|
||||
session.writeAndFlush(byteBuf);
|
||||
session.putBackMassageToMap(byteBuf);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue