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