tomdev/ioGame
过去、现在、将来都不会有商业版本,所有功能全部开源!
只做真的完全式开源,拒绝虚假开源,售卖商业版,不搞短暂维护!
承诺项目的维护周期是十年起步, 2022-03-01起,至少十年维护期!
提供高质量的使用文档!
.
开源地址: 基于 sofa-bolt 的网络游戏框架-源码地址
在线文档: 基于 sofa-bolt 的网络游戏框架-在线文档
推荐大家看在线文档,排版好一些,README 上看有点乱!
愿景
让网络游戏服务器的编程变得轻松简单!
ioGame 是一个由 java 语言编写的网络游戏服务器框架。适用于回合制游戏、策略游戏、即时战斗游戏,等游戏服务器的开发。具有高性能、稳定、易用易扩展、超好编程体验等特点。可做为 H5(HTML5)、手游、端游的游戏服务器。
在这个网络游戏框架中能让你遗忘Netty,你几乎没有机会能直接的接触到 Netty 的复杂,但却能享受 Netty 带来的高性能。对开发者要求低,为开发者节约开发时间,为企业减少人工成本。
ioGame 可以很方便的与 spring 集成。支持多服多进程的方式部署,也支持多服单进程的方式部署。
ioGame 是国内首个基于蚂蚁金服 sofa-bolt 的网络游戏框架。
通过 ioGame,可以快速的搭建一个稳定的、高性能的、分步式的网络游戏服务器,与游戏前端进行通信!
源码内置了一个坦克射击游戏的示例,可直接运行。
坦克射击游戏是基于FXGL引擎(纯java的游戏引擎)开发的。
通过示例,可以快速的掌握网络游戏编程!
游戏示例在线文档
ioGame 的关注点:
线程模型,基于disruptor环形数组来消费业务 注重开发体验 插件机制,扩展性高 异常机制 游戏文档生成 支持 JSR303+ jprotobuf通信协议的友好支持 业务代码定位--神级特性 (可以让你知道哪些业务方法被掉用了,并能快速的跳转到对应的业务代码中)内置多种可选模块,可按需选择,以方便应用开发:
领域事件 (disruptor 实现类似Spring事件驱动模型 ApplicationEvent) 任务延时器 (将来某个时间可对任务进行执行、暂停、取消等操作,并不是类似 Quartz 的任务调度) 多环境切换 (不同运行环境下的配置支持) light-jprotobuf (补足 jprotobuf 不能让多个对象在单个 .proto 源文件中生成的需求,并简化jprotobuf对源文件的注释)置的其他功能:
心跳相关 用户上线、离线相关的钩子方法 UserSessions (对所有用户UserSession的管理,统计在线用户等) UserSession (与 channel 是 1:1 的关系,可取到对应的 userId、channel 等信息。) 登录相关游戏服务器通信相关:
多个逻辑服之间可以相互掉用 广播消息给全服用户 广播消息给多个指定用户 单播消息给指定用户服务器相关:
动态添加与扩展游戏逻辑服 网关服 - 负载均衡逻辑服 对外服 - 保持用户长连接集成相关:
spring 集成 (业务框架可以方便的与 spring 进行集成,5 行代码)已完成的示例:
示例代码在源码 example/ 目录下
多服单进程示例 - DemoApplication.java spring集成示例 - DemoSpringBootApplication 多个逻辑服之间相互掉用示例 - DemoInteractionApplication后续计划:
抽象通用的游戏逻辑 (进一步减少开发实践过程中的工作量) 步骤表 帧同步 状态同步java 网络游戏服务器简介
游戏框架:ioGame
ioGame 是国内首个基于蚂蚁金服 sofa-bolt 的网络游戏框架,游戏框架由 [网络通信框架] 和 [业务框架] 组成。
网络通信框架:负责服务器之间的网络通信
业务框架:负责业务逻辑的处理方式和编写方式
这是一个注重开发体验、稳定、高性能的服务器、高可扩展、简单上手的游戏框架。 游戏框架借助于蚂蚁金服 sofa-bolt 通信框架来提供稳定、高性能。 即使之前没有游戏编程的经验,也能参与到游戏编程中。 游戏框架致力于屏蔽通信细节,为了让 Java 程序员能将更多的精力放在基于游戏框架的业务逻辑实现上! 业务框架注重开发体验,提供异常机制、游戏业务文档生成、支持 JSR303+、业务线程编排、屏蔽 NIO 等细节。 让游戏开发者做尽可能少的事。如果你之前具备一些游戏开发或者 web MVC 的知识会更容易的上手游戏服务器的开发。
网络通信框架 - SOFABolt
SOFABolt 是蚂蚁金融服务集团开发的一套基于 Netty 实现的网络通信框架。
为了让 Java 程序员能将更多的精力放在基于网络通信的业务逻辑实现上,而不是过多的纠结于网络底层 NIO 的实现以及处理难以调试的网络问题,Netty 应运而生。 为了让中间件开发者能将更多的精力放在产品功能特性实现上,而不是重复地一遍遍制造通信框架的轮子,SOFABolt 应运而生。Bolt 名字取自迪士尼动画-闪电狗,是一个基于 Netty 最佳实践的轻量、易用、高性能、易扩展的通信框架。
业务框架
如果说SOFABolt为了让 Java 程序员能将更多的精力放在基于网络通信的业务逻辑实现上。而业务框架正是解决业务逻辑如何方便的实现这一问题上。业务框架是游戏框架的一部份,职责是简化程序员的业务逻辑实现。业务框架使程序员能够快速的开始编写游戏业务。在开发阶段可快速定位业务代码,请求响应监控,方便日志定位(插件实现)。
特点:
跨NIO框架(屏蔽 NIO), 可以做到业务代码不做任何的改动,就能轻松实现NIO框架的切换.(netty mina 这些都属于NIO框架)
线程模型,基于disruptor环形数组来消费业务
注重开发体验
插件机制,扩展性高
异常机制
游戏文档生成
支持 JSR303+
jprotobuf通信协议的友好支持
快速入门
业务交互
抽象的说,游戏前端与游戏服务器的的交互由上图组成。游戏前端与游戏服务器可以自由的双向交互,交互的业务数据由 .proto 作为载体。
协议文件
协议文件是对业务数据的描述载体,用于游戏前端与游戏服务的数据交互。Protocol Buffers (ProtocolBuffer/ protobuf )是Google公司开发的一种数据描述语言。也简称 PB。当然协议文件描述还可以是 json、xml或者任意自定义的,因为最后传输时会转换为二进制。但游戏开发中 PB 是目前的最佳。
游戏前端
游戏前端可以是 Unity、 UE(虚幻)、 Cocos或者其他的游戏引擎。游戏前端与用户的接触最为直接。
游戏服务器
游戏服务器处理实际的用户等其他的业务数据。
快速入门代码示例
这里主要介绍游戏服务器,毕竟是游戏服务器的框架。下面这个示例介绍了服务器编程可以变得如此简单。
Proto 协议文件定义首先我们自定义一个协议文件,这个协议文件作为我们的业务载体描述。这个协议是纯java代码编写的,使用的是 jprotobuf, jprotobuf 是对 google protobuf 的简化使用,性能同等。
/** 请求 */ @ProtobufClass @FieldDefaults(level = AccessLevel.PUBLIC) public class HelloReq { String name; } Action
游戏服务器的编程,游戏服务器接收业务数据后,对业务数据进行处理;
@ActionController(1) public class DemoAction { @ActionMethod(0) public HelloReq here(HelloReq helloReq) { HelloReq newHelloReq = new HelloReq(); newHelloReq.name = helloReq.name + ", I'm here "; return newHelloReq; } }
一个方法在业务框架中表示一个 Action(既一个业务动作)。
方法声名的参数是用于接收前端传入的业务数据,在方法 return 时,数据就可以被游戏前端接收到。程序员可以不需要关心业务框架的内部细节。
从上面的示例可以看出,这和普通的 java 类并无区别。如果只负责编写游戏业务,那么对于业务框架的学习可以到此为止了。
游戏编程就是如此简单!
问:我可以开始游戏服务器的编程了吗?
是的,你已经可以开始游戏服务器的编程了。
访问示例(控制台)当我们访问 here 方法时(通常由游戏前端来请求),控制台将会打印
┏━━━━━ Debug. [(DemoAction.java:4).here] ━━━ [cmd:1 - subCmd:0 - cmdMerge:65536] ┣ userId: 888 ┣ 参数: helloReq : HelloReq(name=塔姆) ┣ 响应: HelloReq(name=塔姆, I'm here ) ┣ 时间: 0 ms (业务方法总耗时) ┗━━━━━ Debug [DemoAction.java] ━━━
Debug. [(DemoAction.java:4).here]: 表示执行业务的是 DemoAction 类下的 here 方法,4 表示业务方法所在的代码行数。在工具中点击控制台的 DemoAction.java:4 这条信息,就可以跳转到对应的代码中(快速导航到对应的代码)。
userId :
当前发起请求的 用户 id。
参数 :
通常是游戏前端传入的值。
响应 :
通常是业务方法返回的值 ,业务框架会把这个返回值推送到游戏前端。
时间 :
执行业务方法总耗时,我们可根据业务方法总耗时的时长来优化业务。
路由信息 :
路由是唯一的访问地址。
有了以上信息,游戏开发者可以很快的定位问题。
如果没有可视化的信息,开发中会浪费很多时间在前后端的沟通上。
问题包括:
是否传参问题 (游戏前端说传了)
是否响应问题(游戏后端说返回了)
业务执行时长问题 (游戏前端说没收到响应, 游戏后端说早就响应了)
其中代码导航可以让开发者快速的跳转到业务类对应代码中,在多人合作的项目中,可以快速的知道业务经过了哪些方法的执行,使得我们可以快速的进行阅读或修改;
适合人群?
长期从事 web 内部系统开发人员, 想了解游戏的 刚从事游戏开发的 未从事过游戏开发但却对其感兴趣的 对设计模式在实践中的应用和 sofa-bolt 有兴趣的学习者推荐实际编程经验一年以上的人员
快速从零编写服务器完整示例
如果觉得 ioGame 适合你,可以看一下 快速从零编写服务器完整示例 。在这个示例中,你可以用很少的代码实现一个完整的、可运行的、高性能的、稳定的服务器。
坦克游戏示例
ioGame 内提供了一个基于 FXGL 游戏引擎的游戏示例 (坦克射击启动文档),FXGL 是纯 java 开发的一个游戏引擎,可以在项目中直接运行。
运行 TankApp.java 文件就可以启动游戏了。
原计划用 U3D 来做游戏示例的,但想到大伙还得安装 u3d 的环境,就用 FXGL 来做游戏示例了。
参考
什么是 Action。
快速从零编写服务器完整示例
坦克示例(坦克游戏前端)。
交流群
Apache License Version 2.0, January 2004 https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] # iohao.com . 渔民小镇 Copyright (C) 2021 double joker (262610965@qq.com) . All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License..
网址: tomdev/ioGame http://www.hyxgl.com/newsview364825.html推荐资讯
- 1老六爱找茬美女的烦恼怎么过- 4999
- 2博德之门3黄金雏龙法杖怎么得 4869
- 3《大侠立志传》剿灭摸金门任务 4312
- 4代号破晓官方正版角色介绍 4023
- 5赛马娘锻炼到底的伙伴支援卡事 3802
- 6闪烁之光11月兑换码大全20 3774
- 7原神原海异种刷怪路线-原神原 3547
- 8爆梗找茬王厕所特工怎么通关- 3542
- 9《我的世界》领地删除指令是什 3440
- 10原神开局星落湖怎么出去 原神 3426