session
parent
26016b3bf0
commit
d30972da3c
|
@ -8,13 +8,11 @@ import com.ljsd.jieling.NetWorkFactory;
|
||||||
import com.ljsd.jieling.config.json.CoreSettings;
|
import com.ljsd.jieling.config.json.CoreSettings;
|
||||||
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.logic.fight.CheckFight;
|
|
||||||
import com.ljsd.jieling.netty.config.EndPortCfg;
|
import com.ljsd.jieling.netty.config.EndPortCfg;
|
||||||
import com.ljsd.jieling.netty.server.NettyGameServer;
|
import com.ljsd.jieling.netty.server.NettyGameServer;
|
||||||
import com.ljsd.jieling.network.NettyProperties;
|
import com.ljsd.jieling.network.NettyProperties;
|
||||||
import com.ljsd.jieling.network.NettyServerAutoConfiguration;
|
import com.ljsd.jieling.network.NettyServerAutoConfiguration;
|
||||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
import com.ljsd.jieling.network.server.SessionManager;
|
||||||
import com.ljsd.jieling.session.GameSession;
|
|
||||||
import com.ljsd.jieling.session.GameSessionFactory;
|
import com.ljsd.jieling.session.GameSessionFactory;
|
||||||
import com.ljsd.jieling.thrift.RPCSceneServerTask;
|
import com.ljsd.jieling.thrift.RPCSceneServerTask;
|
||||||
import com.ljsd.jieling.thrift.pool.ThriftPoolUtils;
|
import com.ljsd.jieling.thrift.pool.ThriftPoolUtils;
|
||||||
|
@ -65,7 +63,6 @@ public class BattleServerApplication {
|
||||||
ThriftPoolUtils.getInstance().initContext();
|
ThriftPoolUtils.getInstance().initContext();
|
||||||
new RPCSceneServerTask(configurableApplicationContext).start();
|
new RPCSceneServerTask(configurableApplicationContext).start();
|
||||||
// 加载lua文件
|
// 加载lua文件
|
||||||
CheckFight.getInstance().init("luafight/BattleMain.lua");
|
|
||||||
final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class);
|
final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class);
|
||||||
NettyProperties properties = netServerConfig.getNettyProperties();
|
NettyProperties properties = netServerConfig.getNettyProperties();
|
||||||
register(properties);
|
register(properties);
|
||||||
|
@ -77,16 +74,10 @@ public class BattleServerApplication {
|
||||||
}));
|
}));
|
||||||
try {
|
try {
|
||||||
LOGGER.info("main->BattleServerApplication start...");
|
LOGGER.info("main->BattleServerApplication start...");
|
||||||
GameSessionFactory gameSessionFactory = () -> new ISession();
|
|
||||||
|
|
||||||
// nettyServer = new NettyGameServer(properties.getTcpPort(), properties.getReadTimeout(),
|
|
||||||
// properties.getWriteTimeout(), properties.getAllTimeout(),BloodyProtocolsManager.getInstance(),
|
|
||||||
// gameSessionFactory);
|
|
||||||
|
|
||||||
nettyServer = NetWorkFactory.getServer(new EndPortCfg(properties.getTcpPort(), properties.getReadTimeout(),
|
nettyServer = NetWorkFactory.getServer(new EndPortCfg(properties.getTcpPort(), properties.getReadTimeout(),
|
||||||
properties.getWriteTimeout(), properties.getAllTimeout()), ProtocolsManager.getInstance(),
|
properties.getWriteTimeout(), properties.getAllTimeout()), SessionManager.getInstance());
|
||||||
gameSessionFactory);
|
|
||||||
nettyServer.start();
|
nettyServer.start();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("main->msg={}", e.getMessage(), e);
|
LOGGER.error("main->msg={}", e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,12 @@ import com.ljsd.battle.util.HeroLogic;
|
||||||
import com.ljsd.battle.vo.FamilyHeroInfo;
|
import com.ljsd.battle.vo.FamilyHeroInfo;
|
||||||
import com.ljsd.battle.vo.HeroAttributeEnum;
|
import com.ljsd.battle.vo.HeroAttributeEnum;
|
||||||
import com.ljsd.battle.vo.UserBloodySnpInfo;
|
import com.ljsd.battle.vo.UserBloodySnpInfo;
|
||||||
|
import com.ljsd.fight.CheckFight;
|
||||||
|
import com.ljsd.fight.FightType;
|
||||||
import config.*;
|
import config.*;
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.globals.Global;
|
||||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
|
||||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||||
import com.ljsd.jieling.logic.fight.FightType;
|
|
||||||
import com.ljsd.jieling.protocols.CommonProto;
|
import com.ljsd.jieling.protocols.CommonProto;
|
||||||
import com.ljsd.jieling.util.FightDataUtil;
|
import com.ljsd.jieling.util.FightDataUtil;
|
||||||
import com.ljsd.jieling.util.MonsterUtil;
|
import com.ljsd.jieling.util.MonsterUtil;
|
||||||
|
|
|
@ -1706,6 +1706,24 @@ public final class ArenaInfoProto {
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
com.ljsd.jieling.protocols.CommonProto.FightDataOrBuilder getFightDataOrBuilder();
|
com.ljsd.jieling.protocols.CommonProto.FightDataOrBuilder getFightDataOrBuilder();
|
||||||
|
|
||||||
|
// optional int32 fightResult = 5;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
boolean hasFightResult();
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
int getFightResult();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Protobuf type {@code com.ljsd.jieling.protocols.ArenaChallengeResponse}
|
* Protobuf type {@code com.ljsd.jieling.protocols.ArenaChallengeResponse}
|
||||||
|
@ -1789,6 +1807,11 @@ public final class ArenaInfoProto {
|
||||||
bitField0_ |= 0x00000004;
|
bitField0_ |= 0x00000004;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 40: {
|
||||||
|
bitField0_ |= 0x00000008;
|
||||||
|
fightResult_ = input.readInt32();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||||
|
@ -1970,11 +1993,36 @@ public final class ArenaInfoProto {
|
||||||
return fightData_;
|
return fightData_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional int32 fightResult = 5;
|
||||||
|
public static final int FIGHTRESULT_FIELD_NUMBER = 5;
|
||||||
|
private int fightResult_;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public boolean hasFightResult() {
|
||||||
|
return ((bitField0_ & 0x00000008) == 0x00000008);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public int getFightResult() {
|
||||||
|
return fightResult_;
|
||||||
|
}
|
||||||
|
|
||||||
private void initFields() {
|
private void initFields() {
|
||||||
myScoreChange_ = 0;
|
myScoreChange_ = 0;
|
||||||
defScoreChange_ = 0;
|
defScoreChange_ = 0;
|
||||||
arenaEnemys_ = java.util.Collections.emptyList();
|
arenaEnemys_ = java.util.Collections.emptyList();
|
||||||
fightData_ = com.ljsd.jieling.protocols.CommonProto.FightData.getDefaultInstance();
|
fightData_ = com.ljsd.jieling.protocols.CommonProto.FightData.getDefaultInstance();
|
||||||
|
fightResult_ = 0;
|
||||||
}
|
}
|
||||||
private byte memoizedIsInitialized = -1;
|
private byte memoizedIsInitialized = -1;
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
|
@ -2000,6 +2048,9 @@ public final class ArenaInfoProto {
|
||||||
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
if (((bitField0_ & 0x00000004) == 0x00000004)) {
|
||||||
output.writeMessage(4, fightData_);
|
output.writeMessage(4, fightData_);
|
||||||
}
|
}
|
||||||
|
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||||
|
output.writeInt32(5, fightResult_);
|
||||||
|
}
|
||||||
getUnknownFields().writeTo(output);
|
getUnknownFields().writeTo(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2025,6 +2076,10 @@ public final class ArenaInfoProto {
|
||||||
size += com.google.protobuf.CodedOutputStream
|
size += com.google.protobuf.CodedOutputStream
|
||||||
.computeMessageSize(4, fightData_);
|
.computeMessageSize(4, fightData_);
|
||||||
}
|
}
|
||||||
|
if (((bitField0_ & 0x00000008) == 0x00000008)) {
|
||||||
|
size += com.google.protobuf.CodedOutputStream
|
||||||
|
.computeInt32Size(5, fightResult_);
|
||||||
|
}
|
||||||
size += getUnknownFields().getSerializedSize();
|
size += getUnknownFields().getSerializedSize();
|
||||||
memoizedSerializedSize = size;
|
memoizedSerializedSize = size;
|
||||||
return size;
|
return size;
|
||||||
|
@ -2159,6 +2214,8 @@ public final class ArenaInfoProto {
|
||||||
fightDataBuilder_.clear();
|
fightDataBuilder_.clear();
|
||||||
}
|
}
|
||||||
bitField0_ = (bitField0_ & ~0x00000008);
|
bitField0_ = (bitField0_ & ~0x00000008);
|
||||||
|
fightResult_ = 0;
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000010);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2212,6 +2269,10 @@ public final class ArenaInfoProto {
|
||||||
} else {
|
} else {
|
||||||
result.fightData_ = fightDataBuilder_.build();
|
result.fightData_ = fightDataBuilder_.build();
|
||||||
}
|
}
|
||||||
|
if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
|
||||||
|
to_bitField0_ |= 0x00000008;
|
||||||
|
}
|
||||||
|
result.fightResult_ = fightResult_;
|
||||||
result.bitField0_ = to_bitField0_;
|
result.bitField0_ = to_bitField0_;
|
||||||
onBuilt();
|
onBuilt();
|
||||||
return result;
|
return result;
|
||||||
|
@ -2263,6 +2324,9 @@ public final class ArenaInfoProto {
|
||||||
if (other.hasFightData()) {
|
if (other.hasFightData()) {
|
||||||
mergeFightData(other.getFightData());
|
mergeFightData(other.getFightData());
|
||||||
}
|
}
|
||||||
|
if (other.hasFightResult()) {
|
||||||
|
setFightResult(other.getFightResult());
|
||||||
|
}
|
||||||
this.mergeUnknownFields(other.getUnknownFields());
|
this.mergeUnknownFields(other.getUnknownFields());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -2853,6 +2917,55 @@ public final class ArenaInfoProto {
|
||||||
return fightDataBuilder_;
|
return fightDataBuilder_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional int32 fightResult = 5;
|
||||||
|
private int fightResult_ ;
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public boolean hasFightResult() {
|
||||||
|
return ((bitField0_ & 0x00000010) == 0x00000010);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public int getFightResult() {
|
||||||
|
return fightResult_;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public Builder setFightResult(int value) {
|
||||||
|
bitField0_ |= 0x00000010;
|
||||||
|
fightResult_ = value;
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <code>optional int32 fightResult = 5;</code>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* 战斗结果
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
public Builder clearFightResult() {
|
||||||
|
bitField0_ = (bitField0_ & ~0x00000010);
|
||||||
|
fightResult_ = 0;
|
||||||
|
onChanged();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// @@protoc_insertion_point(builder_scope:com.ljsd.jieling.protocols.ArenaChallengeResponse)
|
// @@protoc_insertion_point(builder_scope:com.ljsd.jieling.protocols.ArenaChallengeResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6443,23 +6556,24 @@ public final class ArenaInfoProto {
|
||||||
"jsd.jieling.protocols.ArenaInfo\"\'\n\027GetAr" +
|
"jsd.jieling.protocols.ArenaInfo\"\'\n\027GetAr" +
|
||||||
"enaRankInfoRequest\022\014\n\004page\030\001 \001(\005\"P\n\025Aren" +
|
"enaRankInfoRequest\022\014\n\004page\030\001 \001(\005\"P\n\025Aren" +
|
||||||
"aChallengeRequest\022\016\n\006teamId\030\001 \001(\005\022\024\n\014cha" +
|
"aChallengeRequest\022\016\n\006teamId\030\001 \001(\005\022\024\n\014cha" +
|
||||||
"llengeUid\030\002 \001(\005\022\021\n\tskipFight\030\003 \001(\005\"\276\001\n\026A" +
|
"llengeUid\030\002 \001(\005\022\021\n\tskipFight\030\003 \001(\005\"\323\001\n\026A" +
|
||||||
"renaChallengeResponse\022\025\n\rmyScoreChange\030\001" +
|
"renaChallengeResponse\022\025\n\rmyScoreChange\030\001" +
|
||||||
" \001(\005\022\026\n\016defScoreChange\030\002 \001(\005\022;\n\013arenaEne" +
|
" \001(\005\022\026\n\016defScoreChange\030\002 \001(\005\022;\n\013arenaEne" +
|
||||||
"mys\030\003 \003(\0132&.com.ljsd.jieling.protocols.A",
|
"mys\030\003 \003(\0132&.com.ljsd.jieling.protocols.A",
|
||||||
"renaEnemy\0228\n\tfightData\030\004 \001(\0132%.com.ljsd." +
|
"renaEnemy\0228\n\tfightData\030\004 \001(\0132%.com.ljsd." +
|
||||||
"jieling.protocols.FightData\"v\n\030GetArenaR" +
|
"jieling.protocols.FightData\022\023\n\013fightResu" +
|
||||||
"ankInfoResponse\0229\n\trankInfos\030\001 \003(\0132&.com" +
|
"lt\030\005 \001(\005\"v\n\030GetArenaRankInfoResponse\0229\n\t" +
|
||||||
".ljsd.jieling.protocols.ArenaEnemy\022\017\n\007my" +
|
"rankInfos\030\001 \003(\0132&.com.ljsd.jieling.proto" +
|
||||||
"score\030\002 \001(\005\022\016\n\006myRank\030\003 \001(\005\"R\n\023ArenaRand" +
|
"cols.ArenaEnemy\022\017\n\007myscore\030\002 \001(\005\022\016\n\006myRa" +
|
||||||
"omResponse\022;\n\013arenaEnemys\030\001 \003(\0132&.com.lj" +
|
"nk\030\003 \001(\005\"R\n\023ArenaRandomResponse\022;\n\013arena" +
|
||||||
"sd.jieling.protocols.ArenaEnemy\"_\n\027Arena" +
|
"Enemys\030\001 \003(\0132&.com.ljsd.jieling.protocol" +
|
||||||
"RecordInfoResponse\022D\n\017arenaRecordInfo\030\001 " +
|
"s.ArenaEnemy\"_\n\027ArenaRecordInfoResponse\022" +
|
||||||
"\003(\0132+.com.ljsd.jieling.protocols.ArenaRe" +
|
"D\n\017arenaRecordInfo\030\001 \003(\0132+.com.ljsd.jiel" +
|
||||||
"cordInfo\";\n\021PlayWithSbRequest\022\024\n\014challen",
|
"ing.protocols.ArenaRecordInfo\";\n\021PlayWit",
|
||||||
"geUid\030\001 \001(\005\022\020\n\010myteamId\030\002 \001(\005\"N\n\022PlayWit" +
|
"hSbRequest\022\024\n\014challengeUid\030\001 \001(\005\022\020\n\010myte" +
|
||||||
"hSbResponse\0228\n\tfightData\030\001 \001(\0132%.com.ljs" +
|
"amId\030\002 \001(\005\"N\n\022PlayWithSbResponse\0228\n\tfigh" +
|
||||||
"d.jieling.protocols.FightDataB\002H\001"
|
"tData\030\001 \001(\0132%.com.ljsd.jieling.protocols" +
|
||||||
|
".FightDataB\002H\001"
|
||||||
};
|
};
|
||||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||||
|
@ -6489,7 +6603,7 @@ public final class ArenaInfoProto {
|
||||||
internal_static_com_ljsd_jieling_protocols_ArenaChallengeResponse_fieldAccessorTable = new
|
internal_static_com_ljsd_jieling_protocols_ArenaChallengeResponse_fieldAccessorTable = new
|
||||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||||
internal_static_com_ljsd_jieling_protocols_ArenaChallengeResponse_descriptor,
|
internal_static_com_ljsd_jieling_protocols_ArenaChallengeResponse_descriptor,
|
||||||
new java.lang.String[] { "MyScoreChange", "DefScoreChange", "ArenaEnemys", "FightData", });
|
new java.lang.String[] { "MyScoreChange", "DefScoreChange", "ArenaEnemys", "FightData", "FightResult", });
|
||||||
internal_static_com_ljsd_jieling_protocols_GetArenaRankInfoResponse_descriptor =
|
internal_static_com_ljsd_jieling_protocols_GetArenaRankInfoResponse_descriptor =
|
||||||
getDescriptor().getMessageTypes().get(4);
|
getDescriptor().getMessageTypes().get(4);
|
||||||
internal_static_com_ljsd_jieling_protocols_GetArenaRankInfoResponse_fieldAccessorTable = new
|
internal_static_com_ljsd_jieling_protocols_GetArenaRankInfoResponse_fieldAccessorTable = new
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -6,6 +6,7 @@ import com.ljsd.battle.room.SceneManager;
|
||||||
import com.ljsd.battle.util.MessageUtil;
|
import com.ljsd.battle.util.MessageUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.ljsd.jieling.core.HandlerLogicThread;
|
||||||
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.exception.ErrorCode;
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
@ -76,47 +77,7 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
|
||||||
handlers.put(handler.getMessageCode().getNumber(), handler);
|
handlers.put(handler.getMessageCode().getNumber(), handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void processMessage(PacketNetData packetNetData) {
|
||||||
public void processMessage(GameSession gameSession, Object obj) {
|
|
||||||
|
|
||||||
final ISession session = (ISession) gameSession;
|
|
||||||
PacketNetData packetNetData = new PacketNetData((byte[]) obj);
|
|
||||||
if (packetNetData.getMsgId()==1000){
|
|
||||||
dealHeartBeat(session);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packetNetData.getMsgId()== MessageTypeProto.MessageType.ROOM_LOGIN_REQEUST_VALUE){
|
|
||||||
|
|
||||||
//初始化session
|
|
||||||
if (!sessionInit(session,packetNetData)){
|
|
||||||
MessageUtil.sendErrorCode(session,0,"您的账号token不正确,请退出游戏重新登陆!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//刷新token
|
|
||||||
refreshToken(session);
|
|
||||||
//踢下线
|
|
||||||
//在线列表加入session
|
|
||||||
OnlineUserManager.userOnline(session.getUid(),session);
|
|
||||||
}
|
|
||||||
if(packetNetData.getMsgId() == MessageTypeProto.MessageType.ACK_INDICATION_REQUEST_VALUE){
|
|
||||||
ackIndication(session,packetNetData.getIndex());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//处理心跳
|
|
||||||
if (packetNetData.getMsgId()==1000){
|
|
||||||
dealHeartBeat(session);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( packetNetData.getMsgId()== MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
|
||||||
processReconnect(session);
|
|
||||||
LOGGER.info("the uid={} process reconnect",session.getUid());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LOGGER.info("request commond : " + packetNetData.getMsgId());
|
|
||||||
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
|
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
|
||||||
if (baseHandler == null) {
|
if (baseHandler == null) {
|
||||||
LOGGER.info("request unknow commond : " + packetNetData.getMsgId());
|
LOGGER.info("request unknow commond : " + packetNetData.getMsgId());
|
||||||
|
@ -126,6 +87,7 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean addEntry(PacketNetData packetNetData) {
|
public boolean addEntry(PacketNetData packetNetData) {
|
||||||
int userId = packetNetData.getUserId();
|
int userId = packetNetData.getUserId();
|
||||||
try {
|
try {
|
||||||
|
@ -222,108 +184,6 @@ public class BloodyProtocolsManager implements ProtocolsAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void offLine(GameSession gameSession) {
|
|
||||||
LOGGER.info("player offLine ...");
|
|
||||||
ISession session = (ISession) gameSession;
|
|
||||||
synchronized (session) {
|
|
||||||
|
|
||||||
|
|
||||||
if(session.getOfflineType() == ErrorCode.reloginCode){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SceneManager.whenUserOffline(session.getUid());
|
|
||||||
if (session.getCtx() != null) {
|
|
||||||
GameMessageHandler.allChannels.remove(session.getCtx().channel());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session.getUid() == 0) {
|
|
||||||
LOGGER.error("offLine->uid={}", session.getUid());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMessageHandler.currentSessions.remove(session.getUid());
|
|
||||||
try {
|
|
||||||
OnlineUserManager.userOffline(session.getUid());
|
|
||||||
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
|
||||||
if(!indexToIndication.isEmpty() ){
|
|
||||||
String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_BLOODY, Integer.toString(session.getUid()));
|
|
||||||
RedisUtil.getInstence().set(key,gson.toJson(indexToIndication));
|
|
||||||
}
|
|
||||||
|
|
||||||
String key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE_BLOODY, Integer.toString(session.getUid()));
|
|
||||||
RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
|
|
||||||
// 下线处理的逻辑需要添加在这里
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
//保证数据的保存
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readIdel(GameSession gameSession) {
|
|
||||||
final ISession session = (ISession) gameSession;
|
|
||||||
readIdel(session);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readIdel(ISession iSession){
|
|
||||||
//对端口扫描直接关闭
|
|
||||||
if (iSession.getUid() == 0) {
|
|
||||||
iSession.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String remoteAddress = "";
|
|
||||||
if (iSession.getCtx() != null && iSession.getCtx().channel() != null && iSession.getCtx().channel().remoteAddress() != null) {
|
|
||||||
remoteAddress = iSession.getCtx().channel().remoteAddress().toString();
|
|
||||||
}
|
|
||||||
LOGGER.error("readIdea->uid={},iSessionId={},HeartBreatNums={},remoteAddress={};not receieve heart breat",
|
|
||||||
iSession.getUid(), iSession.getId(), iSession.getHeartBreatNums(), remoteAddress);
|
|
||||||
int heartBreatNums = iSession.getHeartBreatNums();
|
|
||||||
heartBreatNums--;
|
|
||||||
if (heartBreatNums <= 0) {
|
|
||||||
if (!GameMessageHandler.currentSessions.containsKey(iSession.getUid())) {
|
|
||||||
iSession.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ISession oldSession = OnlineUserManager.getSessionByUid(iSession.getUid());
|
|
||||||
if (iSession.getId().equals(oldSession.getId())) {
|
|
||||||
kickOldUser(iSession.getUid(), "", 000, "LOSE HEART PACKET!!!!", 0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
iSession.setHeartBreatNums(heartBreatNums);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean kickOldUser(int uid, String uToken, int errorCode, String errorMsg, long requestTime) {
|
|
||||||
if (GameMessageHandler.currentSessions.size() != 0 && GameMessageHandler.currentSessions.keySet().contains(uid)) {
|
|
||||||
if (requestTime != 0 && requestTime < GameMessageHandler.currentSessions.get(uid).getUserLoginTime()) {
|
|
||||||
LOGGER.info("kickOldUser->uid={},requestTime={},userLoginTime={}",
|
|
||||||
uid, requestTime, GameMessageHandler.currentSessions.get(uid).getUserLoginTime());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!OnlineUserManager.checkUidOnline(uid)) {
|
|
||||||
LOGGER.info("kickOldUser->uid={};isNotOnline", uid);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ISession oldSession = OnlineUserManager.getSessionByUid(uid);
|
|
||||||
if (oldSession == null) {
|
|
||||||
LOGGER.info("kickOldUser->uid={};oldSessionisNull", uid);
|
|
||||||
OnlineUserManager.userOffline(uid);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
oldSession.setOfflineType(errorCode);
|
|
||||||
|
|
||||||
offLine(oldSession);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ljsd.network.session;
|
package com.ljsd.network.session;
|
||||||
|
|
||||||
import com.ljsd.jieling.netty.NettyGameSession;
|
import com.ljsd.jieling.netty.NettyGameSession;
|
||||||
|
import com.ljsd.jieling.netty.server.IChannel;
|
||||||
|
import com.ljsd.jieling.protocol.INetWorkHandler;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -51,14 +53,10 @@ public class ISession extends NettyGameSession {
|
||||||
|
|
||||||
private int heartBreatNums = 3;
|
private int heartBreatNums = 3;
|
||||||
|
|
||||||
public ISession() {
|
public ISession(IChannel channel, INetWorkHandler handler) {
|
||||||
this.id = UUID.randomUUID().toString();
|
super(channel, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postClose() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package com.ljsd.network.session;
|
|
||||||
|
|
||||||
import com.ljsd.jieling.session.GameSession;
|
|
||||||
import com.ljsd.jieling.session.GameSessionFactory;
|
|
||||||
|
|
||||||
public class ISessionFactory implements GameSessionFactory {
|
|
||||||
@Override
|
|
||||||
public GameSession createGameSession() {
|
|
||||||
return new ISession();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@ class OnlineRewardActivity extends AbstractActivity {
|
||||||
int[][] values = sActivityRewardConfig.getValues();
|
int[][] values = sActivityRewardConfig.getValues();
|
||||||
int missionProgress = activityProgressInfo.getProgrss();
|
int missionProgress = activityProgressInfo.getProgrss();
|
||||||
long now = TimeUtils.now();
|
long now = TimeUtils.now();
|
||||||
long loginTime = session.getLoginTime();
|
long loginTime = session.getUserLoginTime();
|
||||||
int limitTime = values[0][0];
|
int limitTime = values[0][0];
|
||||||
long remainTime = now - loginTime - limitTime * TimeUtils.ONE_MINUTE + missionProgress * TimeUtils.ONE_SECOND;
|
long remainTime = now - loginTime - limitTime * TimeUtils.ONE_MINUTE + missionProgress * TimeUtils.ONE_SECOND;
|
||||||
if (now - loginTime - limitTime * TimeUtils.ONE_MINUTE + missionProgress * TimeUtils.ONE_SECOND < 0) {
|
if (now - loginTime - limitTime * TimeUtils.ONE_MINUTE + missionProgress * TimeUtils.ONE_SECOND < 0) {
|
||||||
|
|
|
@ -390,7 +390,7 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
||||||
if(session.getFiveReady()==1){
|
if(session.getFiveReady()==1){
|
||||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||||
playerInfoManager.setOffLineTime(TimeUtils.now());
|
playerInfoManager.setOffLineTime(TimeUtils.now());
|
||||||
long onlineTime = playerInfoManager.getOffLineTime() - session.getLoginTime();
|
long onlineTime = playerInfoManager.getOffLineTime() - session.getUserLoginTime();
|
||||||
playerInfoManager.addOnlineTime(onlineTime);
|
playerInfoManager.addOnlineTime(onlineTime);
|
||||||
//更新在线时长
|
//更新在线时长
|
||||||
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.OnlineReward,(int)(onlineTime/TimeUtils.ONE_SECOND));
|
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.OnlineReward,(int)(onlineTime/TimeUtils.ONE_SECOND));
|
||||||
|
|
|
@ -19,7 +19,6 @@ public class ISession extends NettyGameSession {
|
||||||
private boolean kick;
|
private boolean kick;
|
||||||
private int fiveReady; //客户端可以接受服务器5点刷新
|
private int fiveReady; //客户端可以接受服务器5点刷新
|
||||||
private byte[] fiveByteBuf; //五点推送数据缓存
|
private byte[] fiveByteBuf; //五点推送数据缓存
|
||||||
private long loginTime;//BI用
|
|
||||||
private int lastMsgId;//最后客户端请求协议
|
private int lastMsgId;//最后客户端请求协议
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,10 +127,6 @@ public class ISession extends NettyGameSession {
|
||||||
return this.indexToMessage.get(index);
|
return this.indexToMessage.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLoginTime() {
|
|
||||||
return loginTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConcurrentHashMap<Integer, IndicationMsg> getIndexToIndication() {
|
public ConcurrentHashMap<Integer, IndicationMsg> getIndexToIndication() {
|
||||||
return indexToIndication;
|
return indexToIndication;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue