mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
临时提交
This commit is contained in:
@@ -2,7 +2,10 @@ package cn.jisol.ngame.frame.controller;
|
||||
|
||||
|
||||
import cn.jisol.ngame.actions.SystemAction;
|
||||
import cn.jisol.ngame.actions.TileSyncAction;
|
||||
import cn.jisol.ngame.actions.entity.TileServerInfo;
|
||||
import cn.jisol.ngame.proto.JNSyncMessage;
|
||||
import cn.jisol.ngame.util.NewsContext;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@@ -22,6 +25,44 @@ import java.util.Objects;
|
||||
@ResponseBody
|
||||
public class DemoController {
|
||||
|
||||
|
||||
//Tile 端口 分配
|
||||
private Integer nTilePort = 9000;
|
||||
|
||||
//Id 分配
|
||||
private Integer nClientId = 1;
|
||||
|
||||
|
||||
@ApiOperation(value = "获取玩家Id")
|
||||
@GetMapping("/sync/tile/client/id")
|
||||
public NewsContext<Integer> getTileClientId(){
|
||||
return NewsContext.onSuccess("查询成功",nClientId++);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取Tile端口")
|
||||
@GetMapping("/sync/tile/port")
|
||||
public NewsContext<Integer> getTilePort(){
|
||||
return NewsContext.onSuccess("查询成功",nTilePort++);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取TileId")
|
||||
@GetMapping("/sync/tile/id")
|
||||
public NewsContext<Integer> getTileId(){
|
||||
return NewsContext.onSuccess("查询成功", TileSyncAction.getNeedTileId());
|
||||
}
|
||||
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="index",value="所需Tile区域Id"),
|
||||
})
|
||||
@ApiOperation(value = "获取Tile服务器连接")
|
||||
@GetMapping("/sync/tile/server")
|
||||
public NewsContext<TileServerInfo> getTileServer(Integer index){
|
||||
return NewsContext.onSuccess("查询成功",TileSyncAction.getTileInfo(index));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="start",value="帧开始"),
|
||||
@ApiImplicitParam(name="end",value="帧结束")
|
||||
|
@@ -2,6 +2,7 @@ package cn.jisol.ngame.frame.network;
|
||||
|
||||
import cn.jisol.ngame.NSystem;
|
||||
import cn.jisol.ngame.actions.SystemAction;
|
||||
import cn.jisol.ngame.client.NClient;
|
||||
import cn.jisol.ngame.frame.network.client.GClient;
|
||||
import cn.jisol.ngame.network.JNetwork;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,12 +31,13 @@ public class WebSocket {
|
||||
|
||||
GClient client = new GClient(session);
|
||||
CLIENTS.put(session.getId(), client);
|
||||
JNetwork.onConnect(client,client,CLIENTS);
|
||||
|
||||
NSystem.Log("连接WebSocket成功");
|
||||
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
@OnMessage(maxMessageSize = 5242880)
|
||||
public void onMessage(Session session, InputStream inputStream){
|
||||
|
||||
NSystem.Log("收到请求");
|
||||
@@ -47,6 +49,8 @@ public class WebSocket {
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session){
|
||||
NClient client = CLIENTS.get(session.getId());
|
||||
JNetwork.onDisconnect(client,client,CLIENTS);
|
||||
CLIENTS.remove(session.getId());
|
||||
if(CLIENTS.size() == 0){
|
||||
SystemAction.NSyncFrameEnd();
|
||||
|
Reference in New Issue
Block a user