master_ob2
PC-202302260912\Administrator 2023-07-31 14:03:55 +08:00
parent c297f5184a
commit ad334b30d3
7 changed files with 34 additions and 50 deletions

View File

@ -1,17 +1,13 @@
package com.ljsd.jieling.netty.server;
import com.ljsd.jieling.netty.handler.ConnectionWatchdog;
import com.ljsd.jieling.netty.handler.SkyEyeHandler;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.HashedWheelTimer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
@ChannelHandler.Sharable
public class SkyEyeClient {
@ -54,17 +50,14 @@ public class SkyEyeClient {
synchronized (bootstrap) {
ChannelFuture future = bootstrap.connect(host, port);
channel = future.channel();
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture f) throws Exception {
future.addListener((ChannelFutureListener) f -> {
boolean succeed = f.isSuccess();
Channel channel = f.channel();
if (!succeed) {
LOGGER.info("重连失败");
f.channel().pipeline().fireChannelInactive();
} else {
LOGGER.info("重连成功");
}
}
});
}
}
@ -75,7 +68,7 @@ public class SkyEyeClient {
channel.writeAndFlush(request);
return true;// 写消息
}else{
LOGGER.error("【天眼链接失败】由于远端的服务器不能提供服务!{}");
LOGGER.error("【天眼链接失败】由于远端的服务器不能提供服务!");
return false;
}
}
@ -97,10 +90,7 @@ public class SkyEyeClient {
if (!channel.isActive()) {
return false;
}
if (!channel.isWritable()) {
return false;
}
return true;
return channel.isWritable();
}
}

View File

@ -1,11 +1,6 @@
package com.ljsd;
import com.ljsd.jieling.netty.config.EndPortCfg;
import com.ljsd.jieling.netty.server.SkyEyeClient;
import com.ljsd.jieling.network.NettyProperties;
import com.ljsd.jieling.network.NettyServerAutoConfiguration;
import com.ljsd.jieling.network.server.SessionManager;
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,9 +11,9 @@ public class SkyEyeService implements IService {
private static SkyEyeClient skyEyeClient = null;
@Override
public void onStart() throws Exception {
final NettyServerAutoConfiguration netServerConfig = ConfigurableApplicationContextManager.getBean(NettyServerAutoConfiguration.class);
NettyProperties properties = netServerConfig.getNettyProperties();
public void onStart() {
// final NettyServerAutoConfiguration netServerConfig = ConfigurableApplicationContextManager.getBean(NettyServerAutoConfiguration.class);
// NettyProperties properties = netServerConfig.getNettyProperties();
skyEyeClient = new SkyEyeClient();
skyEyeClient.start();
}

View File

@ -33,8 +33,9 @@ public class GuildHelpGetAllRequestHandler extends BaseHandler<Family.GuildHelpG
public GeneratedMessage processWithProto(int uid, Family.GuildHelpGetAllRequest proto) throws Exception {
User user = UserManager.getUser(uid);
if (user == null)
if (user == null) {
throw new ErrorCodeException(ErrorCode.UNKNOWN);
}
//check guild
int guildId = user.getPlayerInfoManager().getGuildId();
if (guildId == 0) {
@ -52,6 +53,9 @@ public class GuildHelpGetAllRequestHandler extends BaseHandler<Family.GuildHelpG
Family.GuildHelpGetAllResponse.Builder builder1 = Family.GuildHelpGetAllResponse.newBuilder();
for (Integer sendUid : sendUids) {
User target = PlayerLogic.getInstance().getUserByRpc(sendUid);
if (target == null){
continue;
}
Set<Map.Entry<Integer, Integer>> entries = target.getGuildMyInfo().getGuidHelpInfo().entrySet();
Family.GuildHelpInfoIndication.Builder builder = Family.GuildHelpInfoIndication.newBuilder();
Map<Integer, Integer> guidHelpHadTakeInfo = target.getGuildMyInfo().getGuidHelpHadTakeInfo();

View File

@ -6,7 +6,10 @@ import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.*;
import com.ljsd.jieling.logic.activity.event.ActivityStateChangeEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.TotalItemEvent;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
@ -14,11 +17,8 @@ import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SActivityRewardConfig;
import config.SGlobalActivity;
import config.SRechargeCommodityNewConfig;
import config.SSuperZhenChong;
import rpc.protocols.CommonProto;
import rpc.protocols.PlayerInfoProto;
import util.TimeUtils;
import java.util.ArrayList;
import java.util.List;
@ -151,9 +151,13 @@ public class MoneyTotalRechargeActivity extends AbstractActivity {
if (mission == null){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"活动信息不存在:"+id);
}
ActivityProgressInfo progressInfo = mission.getActivityMissionMap().get(missionId);
if (progressInfo != null && progressInfo.getState() == 1){
throw new ErrorCodeException(ErrorCode.HAD_TAKE,"活动奖励领取失败:"+mission);
}
SActivityRewardConfig rewardConfig = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
if (!checkValue(mission,rewardConfig)){
throw new ErrorCodeException(ErrorCode.HAD_TAKE,"活动奖励领取失败:"+mission);
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"活动奖励领取失败:"+mission);
}
// 更新数据库信息

View File

@ -216,13 +216,13 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
}
public void setLevel(int level){
updateString("level",level);
this.level = level;
updateString("level",level);
}
public void setStar(int star) {
updateString("star", star);
this.star = star;
updateString("star", star);
}
public int getSpeed() {
@ -230,8 +230,8 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
}
public void setSpeed(int speed) {
updateString("speed", speed);
this.speed = speed;
updateString("speed", speed);
}
public String getId() {
@ -519,8 +519,7 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
public int getPropertyId() {
if (propertyId == 0) {
SCHero scHero = SCHero.getsCHero().get(templateId);
return scHero.getPropertyName();
return Optional.ofNullable(SCHero.getsCHero().get(templateId)).map(SCHero::getPropertyName).orElse(0);
}
return propertyId;
}

View File

@ -450,7 +450,7 @@ public class ExpeditionLogic {
builder1.setHeroTid(familyHeroInfo.getTempleteId());
builder1.setLevel(familyHeroInfo.getLevel());
builder1.setStar(familyHeroInfo.getStar());
builder1.setRemainHp(heroHP.get(s));
builder1.setRemainHp(Optional.ofNullable(heroHP).map(v->v.get(s)).orElse(0.0));
builder1.setPosition(familyHeroInfo.getPosition());
builder1.setGodSoulLv(familyHeroInfo.getGodSoulLv());
builders.add(builder1.build());

View File

@ -35,8 +35,6 @@ import java.util.*;
public class MessageUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
private static HashMap<String, String> skyEyeExtraMap = new HashMap<>();
/**
* gm
*/
@ -75,11 +73,7 @@ public class MessageUtil {
System.arraycopy(backMessage, 0, bytes, pos, backMessage.length);
}
int[] secretKey = Tea.KEY;
byte[] bytes1 = Tea.encrypt2(bytes, secretKey);
// if (backMessage.length != 0) {
// LOGGER.info("wrappedBuffer uid=>{} sendbyte=>{}", uid, bytes1.length);
// }
return bytes1;
return Tea.encrypt2(bytes, secretKey);
}
public static byte[] wrappedBufferSE(GeneratedMessage generatedMessage,SkyEyeProperties properties) {
@ -91,8 +85,6 @@ public class MessageUtil {
byte[] backMessage = generatedMessage.toByteArray();
byte[] verifyByte = new byte[2+4+backMessage.length];
byte[] lengthByte =int2bytes(backMessage.length);
int length = 2+4+backMessage.length;
byte[] bytes = new byte[length];
for(short i = 0;i<verifyByte.length;i++){
if(i<2){
verifyByte[i] = idByte[i];
@ -106,8 +98,8 @@ public class MessageUtil {
}
public static void sendMessage(int[] uids, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
for(int i=0; i<uids.length; i++){
sendMessage(uids[i], result, msgId, generatedMessage, flush);
for (int uid : uids) {
sendMessage(uid, result, msgId, generatedMessage, flush);
}
}
public static void sendMessage(int uid, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {