mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
重构文件
This commit is contained in:
parent
64ab2b0fe5
commit
c4e8237d02
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
||||
[submodule "JNGame"]
|
||||
path = JNGame
|
||||
url = https://gitee.com/jisol/jngame-pro-server
|
||||
[submodule "JisolGameCocos/extensions/ngame"]
|
||||
path = JisolGameCocos/extensions/ngame
|
||||
url = https://gitee.com/jisol/jngame-pro-cocos
|
||||
|
1
JNGame
1
JNGame
@ -1 +0,0 @@
|
||||
Subproject commit bce1ad3522fb8ed1497eee9e01bba38d53e97279
|
@ -23,4 +23,23 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>cn.jisol.game.JGameApplication</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,19 +0,0 @@
|
||||
package cn.jisol.game;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.ComponentScans;
|
||||
|
||||
@ComponentScans({
|
||||
@ComponentScan(
|
||||
value = "cn.jisol.ngame"
|
||||
)
|
||||
})
|
||||
@SpringBootApplication
|
||||
public class JGameApplication {
|
||||
public static void main(String[] args) {
|
||||
ApplicationContext applicationContext = SpringApplication.run(JGameApplication.class);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package cn.jisol.game.config;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
class CorsConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600)
|
||||
.allowedHeaders("*");
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package cn.jisol.game.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";
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package cn.jisol.game.network;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSocketMessageBroker
|
||||
public class NSocketConfigurer implements WebSocketMessageBrokerConfigurer {
|
||||
|
||||
/**
|
||||
* 添加一个服务端点,来接收客户端的连接
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
||||
registry.addEndpoint("/websocket").setAllowedOrigins("*");
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启WebSocket支持
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package cn.jisol.game.network;
|
||||
|
||||
import cn.jisol.ngame.client.NClient;
|
||||
import cn.jisol.ngame.network.JNetwork;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ServerEndpoint(
|
||||
value = "/websocket"
|
||||
)
|
||||
@Controller
|
||||
public class WebSocket {
|
||||
|
||||
public static final Map<String, NClient> CLIENTS = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session){
|
||||
CLIENTS.put(session.getId(),new NClient(session));
|
||||
System.out.printf("[WebSocket] %s 连接成功.\n",session.getId());
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(Session session, InputStream inputStream){
|
||||
JNetwork.onMessage(inputStream,CLIENTS.get(session.getId()),CLIENTS);
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session){
|
||||
CLIENTS.remove(session.getId());
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: cn.jisol.game.JGameApplication
|
||||
|
Loading…
x
Reference in New Issue
Block a user