master_ob2
parent
c297f5184a
commit
ad334b30d3
|
@ -1,17 +1,13 @@
|
||||||
package com.ljsd.jieling.netty.server;
|
package com.ljsd.jieling.netty.server;
|
||||||
|
|
||||||
import com.ljsd.jieling.netty.handler.ConnectionWatchdog;
|
|
||||||
import com.ljsd.jieling.netty.handler.SkyEyeHandler;
|
import com.ljsd.jieling.netty.handler.SkyEyeHandler;
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import io.netty.util.HashedWheelTimer;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@ChannelHandler.Sharable
|
@ChannelHandler.Sharable
|
||||||
public class SkyEyeClient {
|
public class SkyEyeClient {
|
||||||
|
|
||||||
|
@ -54,16 +50,13 @@ public class SkyEyeClient {
|
||||||
synchronized (bootstrap) {
|
synchronized (bootstrap) {
|
||||||
ChannelFuture future = bootstrap.connect(host, port);
|
ChannelFuture future = bootstrap.connect(host, port);
|
||||||
channel = future.channel();
|
channel = future.channel();
|
||||||
future.addListener(new ChannelFutureListener() {
|
future.addListener((ChannelFutureListener) f -> {
|
||||||
public void operationComplete(ChannelFuture f) throws Exception {
|
boolean succeed = f.isSuccess();
|
||||||
boolean succeed = f.isSuccess();
|
if (!succeed) {
|
||||||
Channel channel = f.channel();
|
LOGGER.info("重连失败");
|
||||||
if (!succeed) {
|
f.channel().pipeline().fireChannelInactive();
|
||||||
LOGGER.info("重连失败");
|
} else {
|
||||||
f.channel().pipeline().fireChannelInactive();
|
LOGGER.info("重连成功");
|
||||||
} else {
|
|
||||||
LOGGER.info("重连成功");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -75,7 +68,7 @@ public class SkyEyeClient {
|
||||||
channel.writeAndFlush(request);
|
channel.writeAndFlush(request);
|
||||||
return true;// 写消息
|
return true;// 写消息
|
||||||
}else{
|
}else{
|
||||||
LOGGER.error("【天眼链接失败】由于远端的服务器不能提供服务!{}");
|
LOGGER.error("【天眼链接失败】由于远端的服务器不能提供服务!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,10 +90,7 @@ public class SkyEyeClient {
|
||||||
if (!channel.isActive()) {
|
if (!channel.isActive()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!channel.isWritable()) {
|
return channel.isWritable();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
package com.ljsd;
|
package com.ljsd;
|
||||||
|
|
||||||
import com.ljsd.jieling.netty.config.EndPortCfg;
|
|
||||||
import com.ljsd.jieling.netty.server.SkyEyeClient;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -16,9 +11,9 @@ public class SkyEyeService implements IService {
|
||||||
private static SkyEyeClient skyEyeClient = null;
|
private static SkyEyeClient skyEyeClient = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() throws Exception {
|
public void onStart() {
|
||||||
final NettyServerAutoConfiguration netServerConfig = ConfigurableApplicationContextManager.getBean(NettyServerAutoConfiguration.class);
|
// final NettyServerAutoConfiguration netServerConfig = ConfigurableApplicationContextManager.getBean(NettyServerAutoConfiguration.class);
|
||||||
NettyProperties properties = netServerConfig.getNettyProperties();
|
// NettyProperties properties = netServerConfig.getNettyProperties();
|
||||||
skyEyeClient = new SkyEyeClient();
|
skyEyeClient = new SkyEyeClient();
|
||||||
skyEyeClient.start();
|
skyEyeClient.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,9 @@ public class GuildHelpGetAllRequestHandler extends BaseHandler<Family.GuildHelpG
|
||||||
public GeneratedMessage processWithProto(int uid, Family.GuildHelpGetAllRequest proto) throws Exception {
|
public GeneratedMessage processWithProto(int uid, Family.GuildHelpGetAllRequest proto) throws Exception {
|
||||||
|
|
||||||
User user = UserManager.getUser(uid);
|
User user = UserManager.getUser(uid);
|
||||||
if (user == null)
|
if (user == null) {
|
||||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||||
|
}
|
||||||
//check guild
|
//check guild
|
||||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||||
if (guildId == 0) {
|
if (guildId == 0) {
|
||||||
|
@ -52,6 +53,9 @@ public class GuildHelpGetAllRequestHandler extends BaseHandler<Family.GuildHelpG
|
||||||
Family.GuildHelpGetAllResponse.Builder builder1 = Family.GuildHelpGetAllResponse.newBuilder();
|
Family.GuildHelpGetAllResponse.Builder builder1 = Family.GuildHelpGetAllResponse.newBuilder();
|
||||||
for (Integer sendUid : sendUids) {
|
for (Integer sendUid : sendUids) {
|
||||||
User target = PlayerLogic.getInstance().getUserByRpc(sendUid);
|
User target = PlayerLogic.getInstance().getUserByRpc(sendUid);
|
||||||
|
if (target == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Set<Map.Entry<Integer, Integer>> entries = target.getGuildMyInfo().getGuidHelpInfo().entrySet();
|
Set<Map.Entry<Integer, Integer>> entries = target.getGuildMyInfo().getGuidHelpInfo().entrySet();
|
||||||
Family.GuildHelpInfoIndication.Builder builder = Family.GuildHelpInfoIndication.newBuilder();
|
Family.GuildHelpInfoIndication.Builder builder = Family.GuildHelpInfoIndication.newBuilder();
|
||||||
Map<Integer, Integer> guidHelpHadTakeInfo = target.getGuildMyInfo().getGuidHelpHadTakeInfo();
|
Map<Integer, Integer> guidHelpHadTakeInfo = target.getGuildMyInfo().getGuidHelpHadTakeInfo();
|
||||||
|
|
|
@ -6,7 +6,10 @@ import com.ljsd.jieling.globals.BIReason;
|
||||||
import com.ljsd.jieling.jbean.ActivityMission;
|
import com.ljsd.jieling.jbean.ActivityMission;
|
||||||
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
import com.ljsd.jieling.jbean.ActivityProgressInfo;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
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.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;
|
||||||
|
@ -14,11 +17,8 @@ import com.ljsd.jieling.util.ItemUtil;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
import config.SActivityRewardConfig;
|
import config.SActivityRewardConfig;
|
||||||
import config.SGlobalActivity;
|
import config.SGlobalActivity;
|
||||||
import config.SRechargeCommodityNewConfig;
|
|
||||||
import config.SSuperZhenChong;
|
|
||||||
import rpc.protocols.CommonProto;
|
import rpc.protocols.CommonProto;
|
||||||
import rpc.protocols.PlayerInfoProto;
|
import rpc.protocols.PlayerInfoProto;
|
||||||
import util.TimeUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -151,9 +151,13 @@ public class MoneyTotalRechargeActivity extends AbstractActivity {
|
||||||
if (mission == null){
|
if (mission == null){
|
||||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"活动信息不存在:"+id);
|
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);
|
SActivityRewardConfig rewardConfig = SActivityRewardConfig.getsActivityRewardConfigByMissionId(missionId);
|
||||||
if (!checkValue(mission,rewardConfig)){
|
if (!checkValue(mission,rewardConfig)){
|
||||||
throw new ErrorCodeException(ErrorCode.HAD_TAKE,"活动奖励领取失败:"+mission);
|
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE,"活动奖励领取失败:"+mission);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新数据库信息
|
// 更新数据库信息
|
||||||
|
|
|
@ -216,13 +216,13 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(int level){
|
public void setLevel(int level){
|
||||||
updateString("level",level);
|
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
updateString("level",level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStar(int star) {
|
public void setStar(int star) {
|
||||||
updateString("star", star);
|
|
||||||
this.star = star;
|
this.star = star;
|
||||||
|
updateString("star", star);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSpeed() {
|
public int getSpeed() {
|
||||||
|
@ -230,8 +230,8 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpeed(int speed) {
|
public void setSpeed(int speed) {
|
||||||
updateString("speed", speed);
|
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
|
updateString("speed", speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -519,8 +519,7 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
|
||||||
|
|
||||||
public int getPropertyId() {
|
public int getPropertyId() {
|
||||||
if (propertyId == 0) {
|
if (propertyId == 0) {
|
||||||
SCHero scHero = SCHero.getsCHero().get(templateId);
|
return Optional.ofNullable(SCHero.getsCHero().get(templateId)).map(SCHero::getPropertyName).orElse(0);
|
||||||
return scHero.getPropertyName();
|
|
||||||
}
|
}
|
||||||
return propertyId;
|
return propertyId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,7 +450,7 @@ public class ExpeditionLogic {
|
||||||
builder1.setHeroTid(familyHeroInfo.getTempleteId());
|
builder1.setHeroTid(familyHeroInfo.getTempleteId());
|
||||||
builder1.setLevel(familyHeroInfo.getLevel());
|
builder1.setLevel(familyHeroInfo.getLevel());
|
||||||
builder1.setStar(familyHeroInfo.getStar());
|
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.setPosition(familyHeroInfo.getPosition());
|
||||||
builder1.setGodSoulLv(familyHeroInfo.getGodSoulLv());
|
builder1.setGodSoulLv(familyHeroInfo.getGodSoulLv());
|
||||||
builders.add(builder1.build());
|
builders.add(builder1.build());
|
||||||
|
|
|
@ -35,8 +35,6 @@ import java.util.*;
|
||||||
public class MessageUtil {
|
public class MessageUtil {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
|
||||||
private static HashMap<String, String> skyEyeExtraMap = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 天眼的类型,和gm上的对应
|
* 天眼的类型,和gm上的对应
|
||||||
*/
|
*/
|
||||||
|
@ -75,11 +73,7 @@ public class MessageUtil {
|
||||||
System.arraycopy(backMessage, 0, bytes, pos, backMessage.length);
|
System.arraycopy(backMessage, 0, bytes, pos, backMessage.length);
|
||||||
}
|
}
|
||||||
int[] secretKey = Tea.KEY;
|
int[] secretKey = Tea.KEY;
|
||||||
byte[] bytes1 = Tea.encrypt2(bytes, secretKey);
|
return Tea.encrypt2(bytes, secretKey);
|
||||||
// if (backMessage.length != 0) {
|
|
||||||
// LOGGER.info("wrappedBuffer uid=>{} sendbyte=>{}", uid, bytes1.length);
|
|
||||||
// }
|
|
||||||
return bytes1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] wrappedBufferSE(GeneratedMessage generatedMessage,SkyEyeProperties properties) {
|
public static byte[] wrappedBufferSE(GeneratedMessage generatedMessage,SkyEyeProperties properties) {
|
||||||
|
@ -91,8 +85,6 @@ public class MessageUtil {
|
||||||
byte[] backMessage = generatedMessage.toByteArray();
|
byte[] backMessage = generatedMessage.toByteArray();
|
||||||
byte[] verifyByte = new byte[2+4+backMessage.length];
|
byte[] verifyByte = new byte[2+4+backMessage.length];
|
||||||
byte[] lengthByte =int2bytes(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++){
|
for(short i = 0;i<verifyByte.length;i++){
|
||||||
if(i<2){
|
if(i<2){
|
||||||
verifyByte[i] = idByte[i];
|
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) {
|
public static void sendMessage(int[] uids, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||||
for(int i=0; i<uids.length; i++){
|
for (int uid : uids) {
|
||||||
sendMessage(uids[i], result, msgId, generatedMessage, flush);
|
sendMessage(uid, result, msgId, generatedMessage, flush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void sendMessage(int uid, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
public static void sendMessage(int uid, int result, int msgId, GeneratedMessage generatedMessage, boolean flush) {
|
||||||
|
|
Loading…
Reference in New Issue