Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
fa6f4e546d
|
@ -2,6 +2,9 @@ package com.ljsd.jieling.core;
|
||||||
|
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||||
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||||
|
import com.ljsd.jieling.exception.ErrorUtil;
|
||||||
import com.ljsd.jieling.handler.BaseHandler;
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
|
@ -126,7 +129,7 @@ public class HandlerLogicThread extends Thread{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session.setLastMsgId(msgId);
|
session.setLastMsgId(msgId);
|
||||||
setTransaction(session);
|
SimpleTransaction transaction = setTransaction(session);
|
||||||
BaseHandler baseHandler = ProtocolsManager.getInstance().getHandler(msgId);
|
BaseHandler baseHandler = ProtocolsManager.getInstance().getHandler(msgId);
|
||||||
if(baseHandler == null){
|
if(baseHandler == null){
|
||||||
LOGGER.info("request uid=>{} , msgId=>{}, not find the baseHandler",userId,msgId);
|
LOGGER.info("request uid=>{} , msgId=>{}, not find the baseHandler",userId,msgId);
|
||||||
|
@ -137,33 +140,49 @@ public class HandlerLogicThread extends Thread{
|
||||||
if(!b){
|
if(!b){
|
||||||
MessageUtil.sendErrorResponse(session,0,msgId+1,"funciton not");
|
MessageUtil.sendErrorResponse(session,0,msgId+1,"funciton not");
|
||||||
return;
|
return;
|
||||||
|
// throw new ErrorCodeException(ErrorCode.newDefineCode("funciton not"));
|
||||||
}
|
}
|
||||||
b = checkIsPermit(msgId, session);
|
b = checkIsPermit(msgId, session);
|
||||||
if(!b){
|
if(!b){
|
||||||
MessageUtil.sendErrorResponse(session,0,msgId+1,"在地图探索中,不可以操作");
|
MessageUtil.sendErrorResponse(session,0,msgId+1,"在地图探索中,不可以操作");
|
||||||
return;
|
return;
|
||||||
|
// throw new ErrorCodeException(ErrorCode.newDefineCode("在地图探索中,不可以操作"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long curTimeMillis = System.currentTimeMillis();
|
|
||||||
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
if (msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE) {
|
||||||
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
LOGGER.info("doWork->uid={},mType={};start", userId, MessageTypeProto.MessageType.valueOf(msgId));
|
||||||
}
|
}
|
||||||
|
long curTimeMillis = System.nanoTime();
|
||||||
MissionEventDistributor.requestStart();
|
transaction.beafore();
|
||||||
baseHandler.execute(session, packetNetData);
|
baseHandler.execute(session, packetNetData);
|
||||||
MissionEventDistributor.requestEnd(session,true);
|
transaction.commit();
|
||||||
current().commit();
|
if (msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE) {
|
||||||
MongoUtil.getInstence().lastUpdate();
|
long useTime = System.nanoTime() - curTimeMillis;
|
||||||
if(msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE){
|
LOGGER.info("doWork->uid={},mType={},useTime={},;end", userId, MessageTypeProto.MessageType.valueOf(msgId), useTime);
|
||||||
long useTime = System.currentTimeMillis() - curTimeMillis;
|
|
||||||
LOGGER.info("doWork->uid={},mType={},useTime={},;end", userId, MessageTypeProto.MessageType.valueOf(msgId),useTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (Exception e){
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
|
||||||
SimpleTransaction transaction = current();
|
SimpleTransaction transaction = current();
|
||||||
if(null!=transaction){
|
if(null!=transaction){
|
||||||
ISession session = transaction.getSession();
|
ISession session = transaction.getSession();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
//内部codeErr统一处理
|
||||||
|
if(e instanceof ErrorCodeException){
|
||||||
|
int errCode = ErrorUtil.getExceptionErrorCodeValue(e);
|
||||||
|
if (errCode <= 0) {
|
||||||
|
//打印堆栈定位错误
|
||||||
|
LOGGER.error(ErrorUtil.getExceptionStackTraceFileLineAndMethod(e));
|
||||||
|
}else {
|
||||||
|
LOGGER.info(e.toString());
|
||||||
|
}
|
||||||
|
MessageUtil.sendErrorResponse(session, errCode, session.getLastMsgId() + 1, ErrorUtil.getExceptionMessage(e));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
current().callback();
|
current().callback();
|
||||||
LOGGER.error("\nuser:"+ session.getUid(),e);
|
LOGGER.error("\nuser:"+ session.getUid(),e);
|
||||||
User user = UserManager.getUserInMem(session.getUid());
|
User user = UserManager.getUserInMem(session.getUid());
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ljsd.jieling.core;
|
package com.ljsd.jieling.core;
|
||||||
|
|
||||||
import com.google.protobuf.GeneratedMessage;
|
import com.google.protobuf.GeneratedMessage;
|
||||||
|
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||||
|
import com.ljsd.jieling.logic.mission.event.MissionEventDistributor;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||||
|
@ -67,13 +69,20 @@ public class SimpleTransaction {
|
||||||
dealWhileCommit(transTask);
|
dealWhileCommit(transTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void beafore() throws Exception{
|
||||||
|
MissionEventDistributor.requestStart();
|
||||||
|
}
|
||||||
|
|
||||||
public void commit() {
|
public void commit() throws Exception{
|
||||||
doAddSendCache();
|
doAddSendCache();
|
||||||
for (TransTask transTask : tasks) {
|
for (TransTask transTask : tasks) {
|
||||||
if (!transTask.isCallback())
|
if (!transTask.isCallback())
|
||||||
transTask.run();
|
transTask.run();
|
||||||
}
|
}
|
||||||
|
//miss
|
||||||
|
MissionEventDistributor.requestEnd(session,true);
|
||||||
|
//mongo
|
||||||
|
MongoUtil.getInstence().lastUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void callback() {
|
void callback() {
|
||||||
|
|
|
@ -1,6 +1,38 @@
|
||||||
package com.ljsd.jieling.exception;
|
package com.ljsd.jieling.exception;
|
||||||
|
|
||||||
public class ErrorCode {
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* a——游戏的弹出错误规范
|
||||||
|
* b——错误堆栈抛出打印
|
||||||
|
* 错误提示 前端读配置 后端文字仅做查找和日志用
|
||||||
|
* 1: code>=0 客户端显示根据配置 服务器打印手动添加的描述(默认程序错误发送0 配置“服务器紧急修复中”文字 )
|
||||||
|
* 2: code=-1 客户端显示服务器描述字段 服务器打印手动添加的描述(如道具不足 等级不够等逻辑上不应该出现的错误 用来定位错误)
|
||||||
|
* 3: code= -* 服务器推送 (系统错误 重复登陆 踢用户下线 账号级别的错误推送)
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* 1 2级使用msgId+1响应
|
||||||
|
* 3 走以前的推送
|
||||||
|
*a
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/21 11:23
|
||||||
|
*/
|
||||||
|
public enum ErrorCode implements IErrorCode {
|
||||||
|
|
||||||
|
|
||||||
|
SYS_ERROR_CODE(-100, "系统错误"),
|
||||||
|
RELOGIN_CODE(-101, "重复登陆"),
|
||||||
|
KICK_USER_CODE(-102, "踢用户下线"),
|
||||||
|
|
||||||
|
|
||||||
|
SERVER_SELF_DEFINE(-1, "正在紧急修复中,请稍后再试"),
|
||||||
|
UNKNOWN(0, "正在紧急修复中,请稍后再试"),
|
||||||
|
NAME_USE(1,"该名字已被使用"),
|
||||||
|
NAME_LENTH(2,"名字长度为2-6个字"),
|
||||||
|
LOGIN_ERR(3,"登录密码错误"),
|
||||||
|
USE_NOT_EXIT(5,"该用户不存在"),
|
||||||
|
ITEM_POCKET_IS_FULL(6, "背包已满"),
|
||||||
|
;
|
||||||
|
|
||||||
//系统错误
|
//系统错误
|
||||||
public static final int sysErrorCode = -100;
|
public static final int sysErrorCode = -100;
|
||||||
|
@ -12,4 +44,30 @@ public class ErrorCode {
|
||||||
public static final int kickUserCode = -102;
|
public static final int kickUserCode = -102;
|
||||||
|
|
||||||
|
|
||||||
|
int codeId;
|
||||||
|
String errMsg;
|
||||||
|
|
||||||
|
ErrorCode(int codeId, String errMsg) {
|
||||||
|
this.codeId = codeId;
|
||||||
|
this.errMsg = errMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int code() {
|
||||||
|
return codeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String message() {
|
||||||
|
return errMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ErrorCode reDefineMsg(String errMsg) {
|
||||||
|
this.errMsg = errMsg;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ErrorCode newDefineCode(String errMsg) {
|
||||||
|
return SERVER_SELF_DEFINE.reDefineMsg(errMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.ljsd.jieling.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 逻辑异常包装类
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/21 11:44
|
||||||
|
*/
|
||||||
|
public class ErrorCodeException extends Exception {
|
||||||
|
public ErrorCodeException(ErrorCode errorCode) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final ErrorCode errorCode;
|
||||||
|
|
||||||
|
public ErrorCode getCode() {
|
||||||
|
return this.errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "[CODE: " + this.errorCode.code() + "][" + this.errorCode.message() + "] " + super.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return "" + super.getMessage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.ljsd.jieling.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 异常工具类
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/21 11:23
|
||||||
|
*/
|
||||||
|
public class ErrorUtil {
|
||||||
|
|
||||||
|
public ErrorUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ErrorCode getExceptionErrorCode(Throwable e) {
|
||||||
|
if (e == null) {
|
||||||
|
return ErrorCode.UNKNOWN;
|
||||||
|
} else {
|
||||||
|
Throwable t = e;
|
||||||
|
ErrorCode r = ErrorCode.UNKNOWN;
|
||||||
|
do {
|
||||||
|
if (t instanceof ErrorCodeException) {
|
||||||
|
r = ((ErrorCodeException) t).getCode();
|
||||||
|
}
|
||||||
|
t = t.getCause();
|
||||||
|
} while (t != null);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getExceptionErrorCodeValue(Throwable e) {
|
||||||
|
return getExceptionErrorCode(e).code();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getExceptionMessage(Throwable e) {
|
||||||
|
if (e == null) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Throwable t = e;
|
||||||
|
do {
|
||||||
|
if (!(t instanceof ErrorCodeException)) {
|
||||||
|
builder.append(t.getClass().getSimpleName()).append(":").append(t.getMessage()).append(" ");
|
||||||
|
} else if (t.getMessage() != null && t.getMessage().length() > 0) {
|
||||||
|
builder.append(t.getMessage()).append(" ");
|
||||||
|
}
|
||||||
|
t = t.getCause();
|
||||||
|
} while (t != null);
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务器打印
|
||||||
|
*/
|
||||||
|
public static String getExceptionStackTraceFileLineAndMethod(Throwable e) {
|
||||||
|
if (e == null) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
Throwable t = e;
|
||||||
|
|
||||||
|
while (t != null) {
|
||||||
|
StackTraceElement[] stackTraceElements = t.getStackTrace();
|
||||||
|
if (stackTraceElements != null && stackTraceElements.length > 0) {
|
||||||
|
builder.append(System.getProperty("line.separator"));
|
||||||
|
int var5 = stackTraceElements.length;
|
||||||
|
|
||||||
|
for (StackTraceElement stackTraceElement : stackTraceElements) {
|
||||||
|
builder.append(" at ").append(stackTraceElement).append(System.getProperty("line.separator"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t = t.getCause();
|
||||||
|
if (t != null) {
|
||||||
|
builder.append(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.ljsd.jieling.exception;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 错误提示 前端读配置 后端文字仅做显示用
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/21 11:10
|
||||||
|
*/
|
||||||
|
public interface IErrorCode {
|
||||||
|
|
||||||
|
int code();
|
||||||
|
|
||||||
|
String message();
|
||||||
|
|
||||||
|
}
|
|
@ -141,6 +141,7 @@ public class GMRequestHandler extends BaseHandler{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case GlobalGm.ADOPT_FIGHT_BY_VALUE:
|
case GlobalGm.ADOPT_FIGHT_BY_VALUE:
|
||||||
int fightId = cUser.getMainLevelManager().getFightId();
|
int fightId = cUser.getMainLevelManager().getFightId();
|
||||||
if(SMainLevelConfig.biggerThanFight(fightId,prarm1)){
|
if(SMainLevelConfig.biggerThanFight(fightId,prarm1)){
|
||||||
|
|
|
@ -39,6 +39,13 @@ public enum ActivityTypeEnum {
|
||||||
private int type;
|
private int type;
|
||||||
private Function<Integer, AbstractActivity> toActivityFunction;
|
private Function<Integer, AbstractActivity> toActivityFunction;
|
||||||
private static HashMap<Integer, AbstractActivity> acticityCache = new HashMap<>();
|
private static HashMap<Integer, AbstractActivity> acticityCache = new HashMap<>();
|
||||||
|
private static final HashMap<Integer,ActivityTypeEnum> activityEnumMap = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (ActivityTypeEnum item:ActivityTypeEnum.values()) {
|
||||||
|
activityEnumMap.put(item.getType(),item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ActivityTypeEnum(int type, Function<Integer, AbstractActivity> toActivityFunction) {
|
ActivityTypeEnum(int type, Function<Integer, AbstractActivity> toActivityFunction) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -56,11 +63,13 @@ public enum ActivityTypeEnum {
|
||||||
|
|
||||||
public static AbstractActivity getActicityType(int id) {
|
public static AbstractActivity getActicityType(int id) {
|
||||||
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
|
||||||
for (ActivityTypeEnum activityType:ActivityTypeEnum.values()) {
|
// for (ActivityTypeEnum activityType:ActivityTypeEnum.values()) {
|
||||||
if(activityType.getType()==sGlobalActivity.getType()){
|
// if(activityType.getType()==sGlobalActivity.getType()){
|
||||||
return activityType.toActivity(id);
|
// return activityType.toActivity(id);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
if (activityEnumMap.containsKey(sGlobalActivity.getType()))
|
||||||
|
return activityEnumMap.get(sGlobalActivity.getType()).toActivity(id);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,14 +251,6 @@ public class CombatLogic {
|
||||||
}
|
}
|
||||||
int fightId = mainLevelManager.getFightId();
|
int fightId = mainLevelManager.getFightId();
|
||||||
SMainLevelConfig targetMainLevelConfig = SMainLevelConfig.config.get(fightId);
|
SMainLevelConfig targetMainLevelConfig = SMainLevelConfig.config.get(fightId);
|
||||||
if(mainLevelManager.getState()==-1){
|
|
||||||
for( SMainLevelConfig sMainLevelConfig : SMainLevelConfig.config.values() ){
|
|
||||||
if(sMainLevelConfig.getNextLevel() == mainLevelManager.getFightId()){
|
|
||||||
targetMainLevelConfig = sMainLevelConfig;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int lastTime = mainLevelManager.getLastTime();
|
int lastTime = mainLevelManager.getLastTime();
|
||||||
int now = (int) (System.currentTimeMillis() / 1000);
|
int now = (int) (System.currentTimeMillis() / 1000);
|
||||||
int times = (now - lastTime)/STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getAdventureRefresh();
|
int times = (now - lastTime)/STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getAdventureRefresh();
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package config;
|
||||||
|
|
||||||
|
import manager.STableManager;
|
||||||
|
import manager.Table;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Table(name ="ErrorCodeHint")
|
||||||
|
public class SErrorCodeHint implements BaseConfig {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int showType;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShowType() {
|
||||||
|
return showType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue