GithubHelp home page GithubHelp logo

bitactor / bitactor-cloud-spring Goto Github PK

View Code? Open in Web Editor NEW
58.0 1.0 7.0 170 KB

一款适配Spring Boot,网络层基于Netty的分布式NIO的java服务框架(游戏服务器框架)。底层采用类似dubbo的面向接口的RPC协议,支持tcp、kcp和websocket,可快速开发出一个易维护、易扩展且稳定高的分布式服务,让开发者专注于业务功能的开发。

Home Page: https://www.bitactor.com/

License: Apache License 2.0

Java 100.00%
springboot protobuf cloud game netty bitactor-cloud-spring cluster dubbo game-server gameserver

bitactor-cloud-spring's Introduction

JDK license

介绍

  • Bitactor Cloud 是一款适配Spring Boot,网络层基于Netty的分布式NIO服务框架,可快速开发出一个易维护、易扩展且稳定高的分布式服务,让开发者专注于业务功能的开发
  • 实现了基于注解的消息控制层,让基于长连接网络的请求像 spring MVC 一样简单易用。
  • 参考Apache Dubbo实现的面向接口的定制化RPC,并基于nacos的服务注册中心。
  • 适配springboot,并且继承了springboot的所有特性、达到了松耦合的效果,提高了系统的可重用性、可维护性以及可扩展性

协议

支持的协议

Bitactor协议格式

通用

head packetType
2(short) 1(byte)

MessageData 专有

head packetType protoType msgId commandId data
2(short) 1(byte) 1(byte) 4(int) 4(int) n(byte)

协议名词解释

  • head: 包头指定包体长度,不包括head的长度,head 长度可以通过配置修改
  • packetType: 包类型,见下表
  • protoType:仅用于 MessageData 包 指定序列化类型,支持Protobuf|Json
  • msgId:仅用于 MessageData 包 消息号,单次请求响应消息号相同,每增加一次请求消息号+1,推送消息的msg固定为0
  • commandId:仅用于 MessageData 包 序列化类的简单类名的hashCode,用于序列化&反序列化
  • data:仅用于 MessageData 包 序列化类的byte[]

bitactor协议包类型

基于packetType协议包体分为5种

包类名 packetType值 描述
MessageHandShake 0x01 握手消息
MessageAck 0x02 确认消息
MessageHeartBeat 0x03 心跳消息
MessageData 0x04 数据消息
MessageClose 0x10 关闭消息

开始使用

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/>
    </parent>
    <dependencies>
        <dependency>
             <groupId>com.bitactor.framework.cloud.spring.boot</groupId>
             <artifactId>bitactor-cloud-connector-spring-boot-starter</artifactId>
             <version>LATEST</version>
        </dependency>
    </dependencies>

单服务启动示例

@EnableBitactorConnectorConfiguration
@SpringBootApplication()
@BitactorController(connector = "CONNECTOR")
public class SingleSimpleApplication {
    public static void main(String[] args) throws Throwable {
        SpringApplication.run(SimpleApplication.class, args);
    }
    /**
     * 登录授权
     *
     * @param request LoginAuthReq -> protobuf生成类
     * @param session 
     * @return CommonResp -> protobuf对象
     */
    @BitactorRequestMapping()
    public CommonResp auth(@ProtocolBody LoginAuthReq request, ClientNetSession session) {
        // do something
        return null;
    }
}
spring:
  application:
    name: "CONNECTOR"
  # bitactor框架配置
  bitactor:
    # 网关服务(gateway)对外暴露配置
    connector:
      # 对外暴露的ip&域名
      host: 127.0.0.1
      # 对外暴露的端口,配置该值后将开启网关服
      port: 8899
      # TCP WS KCP
      net-protocol: TCP

分布式服务

分布式服务启用,仅需添加以下依赖即可,具体使用方法以及更多特性请参见 官方文档

    <dependency>
        <groupId>com.bitactor.framework.cloud.spring.boot</groupId>
        <artifactId>bitactor-cloud-cluster-spring-boot-starter</artifactId>
        <version>LATEST</version>
    </dependency>

bitactor-cloud-spring's People

Contributors

bitactor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bitactor-cloud-spring's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.