This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-01-29 02:28:42 +08:00
parent 68c4d5e811
commit 01a4312761
73 changed files with 13939 additions and 42231 deletions

View File

@@ -0,0 +1,53 @@
package cn.jisol.ngame.frame.controller;
import cn.jisol.ngame.actions.SystemAction;
import cn.jisol.ngame.proto.JNSyncMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
@Api(value = "JNGameDemo - API", tags = {"WorldCard - API"})
@RestController
@RequestMapping()
@ResponseBody
public class DemoController {
@ApiImplicitParams({
@ApiImplicitParam(name="start",value="帧开始"),
@ApiImplicitParam(name="end",value="帧结束")
})
@ApiOperation(value = "获取帧同步数据")
@GetMapping("/sync/frame")
public ResponseEntity<byte[]> getSyncFrame(Integer start, Integer end){
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");
if(Objects.isNull(SystemAction.frame))
return ResponseEntity.ok().headers(headers).body(new byte[0]);
JNSyncMessage.JNFrameInfos infos = SystemAction.frame.vGetFrame(start, end);
return ResponseEntity.ok().headers(headers).body(infos.toByteArray());
}
@ApiImplicitParams({
@ApiImplicitParam(name="start",value="帧开始"),
@ApiImplicitParam(name="end",value="帧结束")
})
@ApiOperation(value = "获取帧同步数据")
@GetMapping("/sync/hello")
public String getSyncHello(Integer start, Integer end){
return "HelloWorld";
}
}

View File

@@ -1,6 +1,7 @@
package cn.jisol.ngame.frame.network;
import cn.jisol.ngame.NSystem;
import cn.jisol.ngame.actions.SystemAction;
import cn.jisol.ngame.frame.network.client.GClient;
import cn.jisol.ngame.network.JNetwork;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,7 +47,10 @@ public class WebSocket {
@OnClose
public void onClose(Session session){
CLIENTS.remove(session.getId());
if(CLIENTS.size() == 0){
SystemAction.NSyncFrameEnd();
}
}
}

View File

@@ -0,0 +1,43 @@
package cn.jisol.ngame.frame.swagger;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
@Configuration
@EnableSwagger2WebMvc
public class Swagger {
@Bean(value = "defaultApi")
public Docket defaultApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
//分组名称
.groupName("Game Open")
.select()
//这里指定Controller扫描包路径
// .apis(RequestHandlerSelectors.basePackage("com.github.xiaoymin.knife4j.controller"))
//这里指定扫描有ApiOperation注解的类
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//所有路径
.paths(PathSelectors.any())
//不包含^/inner/.*的路径
//.paths(input -> !input.matches("^/inner/.*"))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Game Open APIs")
.description("Game Open APIs")
.version("1.0")
.build();
}
}