node-pinus / pinus

A fast,scalable,distributed game server framework for Node.js, Powered by TypeScript. 一个TypeScript写的node.js分布式游戏/应用服务器框架(原型基于pomelo)。
https://pinus.io
MIT License
1.81k stars 374 forks source link

关于业务逻辑的热更思考 #916

Open chanayy123 opened 6 months ago

chanayy123 commented 6 months ago

最新版本的example里面有手动热更和自动热更的例子,都是针对remote和handler,简单测过都没问题,关于业务逻辑这块,通过app注册自己的管理类,也能动态修改变量和简单的方法,如果碰到一些方法里面引用了很多其他模块,这个感觉就没法热更修改了,比如类似这样的,里面引用了RoomProto,Code等其他模块: public userLeaveRoomRequest(uid) { let user = this.userArr[uid]; if (user) { if (this.gameStarted && (user.userStatus & RoomProto.userStatusEnum.PLAYING) !== 0 ) { this.sendPopDialogContent(Code.GAME.CAN_NOT_LEAVE_ROOM, [user.chairId]); let response = RoomProto.userLeaveRoomResponse(user.chairId); this.sendRoomDataToAll(response); } else { this.userLeaveRoom(uid); } } }; 能想到的最笨的办法就是把可能需要修改的类都注册进app,这样需要热更修复的时候 外部模块都用app来引用,不知道大家有没有更好的办法?

whtiehack commented 6 months ago

https://github.com/node-pinus/pinus/issues/19