GithubHelp home page GithubHelp logo

ly774508966 / gameserver-6 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jiayaoguang/gameserver

0.0 0.0 0.0 608 KB

This is a java open source game server framework

License: Apache License 2.0

Java 82.71% HTML 4.11% Batchfile 0.20% CSS 0.47% JavaScript 11.34% FreeMarker 1.18%

gameserver-6's Introduction

游戏服务器 更新中...

Java CI License

Maven

<dependency>
    <groupId>com.github.jiayaoguang</groupId>
    <artifactId>gameserver-core</artifactId>
    <version>0.0.1</version>
</dependency>
  • core模块-主要的网络库
  • auth模块-登录服
  • center模块-场景服管理
  • scene模块-场景服
  • proto模块-传送的相关协议

服务器主要采用了netty4.1.19.Final框架处理socket连接, 使用protobuf3.5.1作为发送消息序列化格式, 使用disruptor3.3.2框架去做端口消息的多线程同步

能够处理http,protobuf , json/自定义字节数组 类型的数据

构建处理 protoBuf数据的服务器例子:

 public class PingServer {
     public static void main(String[] args) throws Exception {
         GameServerBootstarp bootstarp = new GameServerBootstarp();
         bootstarp.registerSocketEvent(1, new PingProcessor());
         bootstarp.registerSendEventIdByProto(2, p_scene_sm_response_pong.class);
         //开端口服务
         bootstarp.addTcpService(8080);
         bootstarp.start();
     }
 
     public static class PingProcessor extends ProtoProcessor<p_sm_scene_request_ping> {
 
         public PingProcessor() {
             super(p_sm_scene_request_ping.getDefaultInstance());
         }
 
         @Override
         public void process(Session session, p_sm_scene_request_ping msg) {
             System.out.println("ok , i see ping");
             session.writeMessage(p_scene_sm_response_pong.newBuilder());
         }
     }
 }

http例子代码:

GameServerBootstarp bootstarp = new GameServerBootstarp();

bootstarp.registerHttpEvent("/index", new HttpProcessor() {

    @Override
    public void service(Request request, Response response) {
        response.writeAndFlush( 
            "<html><head></head><body><div align='center'><h1>Hello world!</h1></div><body></html>"
             ); 
    }
    
} );

bootstarp.addHttpService(8080);
bootstarp.start();

更多例子请在test包查看


License

Apache License, Version 2.0 Copyright (C) Apache Software Foundation

gameserver-6's People

Contributors

jiayaoguang avatar

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.