kingston-csj / mmorpg Goto Github PK
View Code? Open in Web Editor NEWspringboot编写的高性能分布式mmorpg手游服务端框架,包含中心服,网关服,游戏服,战斗服等。
springboot编写的高性能分布式mmorpg手游服务端框架,包含中心服,网关服,游戏服,战斗服等。
老哥有没有这个项目的交流群啊、
建议把@MessageMeta的参数放到@RequestMapping,然后把@MessageMeta类型改为参数,例如下面这种:
@RequestMapping(module = Modules.PLAYER, cmd = PlayerService.CMD_REQ_LOGIN)
public void reqPlayerLogin(IoSession session, @MessageMeta ReqPlayerLogin request) {
long playerId = request.getPlayerId();
System.out.println("角色[" + playerId + "]登录");
SessionManager.getInstance().registerSession(playerId, session);
session.sendPacket(new ResPlayerLogin());
}
参考spring mvc的注解,因为是请求响应模型,我觉得这样比较好理解一些
老哥,game_user.sql文件在什么地方啊?
Class<?> clazz = MessageFactory.getInstance().getMessageMeta(NumberUtil.intValue(frame.getId()));
麻烦大佬看看是不是这个方法NumberUtil.intValue(frame.getId())没有找出消息id.
我这边做出修改,单独把moudleId 和cmdId找出来,用了下面这个方法
public Class<? extends Message> getMessageMeta(short module, short cmd) {
Integer key = buildKey(module, cmd);
return getMessageMeta(key);
}
终于看到Netty版的服务器了,想请教一个ByteBuf的问题,我的毕业设计撸了个类似这个项目的编解码工具,遇到了释放ByteBuf的问题,在你的项目里解码是这样的:
private Message readMessage(short module, short cmd, ByteBuf in) {
Class<?> msgClazz = SpringContext.getMessageFactory().createMessage(module, cmd);
try {
Serializer messageCodec = Serializer.getSerializer(msgClazz);
Message message = (Message) messageCodec.decode(in, msgClazz, null);
return message;
} catch (Exception e) {
LoggerUtils.error("读取消息出错,模块号{},类型{},异常{}", new Object[]{module, cmd ,e});
}
return null;
}
然后在decode里是这样:
@Override
public Object decode(ByteBuf in, Class<?> type, Class<?> wrapper) {
try {
Object bean = type.newInstance();
for (FieldCodecMeta fieldMeta:fieldsMeta) {
Field field = fieldMeta.getField();
Serializer fieldCodec = fieldMeta.getSerializer();
Object value = fieldCodec.decode(in, fieldMeta.getType(), fieldMeta.getWrapper());
field.set(bean, value);
}
return bean;
}catch(Exception e) {
e.printStackTrace();
}
return null;
}
这两部就从ByteBuf-->POJO,但是有个问题,这里的ByteBuf需要释放吗?因为return null了,那么TailContext就无法去自动释放这个ByteBuf了吧??是需要在解码结束后手动调用这个吧?
@Override
public Object decode(ByteBuf in, Class<?> type, Class<?> wrapper) {
try {
Object bean = type.newInstance();
for (FieldCodecMeta fieldMeta:fieldsMeta) {
Field field = fieldMeta.getField();
Serializer fieldCodec = fieldMeta.getSerializer();
Object value = fieldCodec.decode(in, fieldMeta.getType(), fieldMeta.getWrapper());
field.set(bean, value);
}
//手动释放ByteBuf
ReferenceCountUtil.release(buf);
return bean;
}catch(Exception e) {
e.printStackTrace();
}
return null;
}
谢谢~
在ide中把server和client都启动了,只有两个console输出了启动日志,接下来呢?client和server的交互什么都看不到
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configResourceRegistry' defined in file [G:\WORK\JavaProgramming\GameProjects\mmorpg\out\production\classes\com\kingston\mmorpg\game\database\config\ConfigResourceRegistry.class]: Initialization of bean failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Null value was assigned to a property [class com.kingston.mmorpg.game.database.config.domain.ConfigSkill.needLevel] of primitive type setter of com.kingston.mmorpg.game.database.config.domain.ConfigSkill.needLevel; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property [class com.kingston.mmorpg.game.database.config.domain.ConfigSkill.needLevel] of primitive type setter of com.kingston.mmorpg.game.database.config.domain.ConfigSkill.needLevel
事务使用@transactional(rollbackFor = Exception.class)怎么无效的,表的引擎也没错
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.