mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
无头模式 裁决
This commit is contained in:
parent
f890be0728
commit
e3781116dc
@ -26,12 +26,12 @@ import { JAPI, JAPIConfig } from "../../extensions/ngame/assets/ngame/util/JAPI"
|
|||||||
import { AppData } from "./AppData";
|
import { AppData } from "./AppData";
|
||||||
import AppAction from "./AppAction";
|
import AppAction from "./AppAction";
|
||||||
|
|
||||||
// let APIPath = `http://localhost:8080`
|
let APIPath = `http://localhost:8080`
|
||||||
// let WsPath = `ws://localhost:8080/websocket`
|
let WsPath = `ws://localhost:8080/websocket`
|
||||||
// let APIPath = `http://192.168.1.23:8080`
|
// let APIPath = `http://192.168.1.23:8080`
|
||||||
// let WsPath = `ws://192.168.1.23:8080/websocket`
|
// let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||||
let APIPath = `http://192.168.0.123:8080`
|
// let APIPath = `http://192.168.0.123:8080`
|
||||||
let WsPath = `ws://192.168.0.123:8080/websocket`
|
// let WsPath = `ws://192.168.0.123:8080/websocket`
|
||||||
// let APIPath = `https://api.pet.jisol.cn`
|
// let APIPath = `https://api.pet.jisol.cn`
|
||||||
// let WsPath = `wss://api.pet.jisol.cn/websocket`
|
// let WsPath = `wss://api.pet.jisol.cn/websocket`
|
||||||
|
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package cn.jisol.game.actions;
|
package cn.jisol.game.actions;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.log.LogFactory;
|
||||||
import cn.jisol.game.network.client.GRefereeClient;
|
import cn.jisol.game.network.client.GRefereeClient;
|
||||||
import cn.jisol.game.proto.GPVPMessage;
|
import cn.jisol.game.proto.GPVPMessage;
|
||||||
import cn.jisol.ngame.actions.core.NAction;
|
import cn.jisol.ngame.actions.core.NAction;
|
||||||
import cn.jisol.ngame.actions.core.NActionMethod;
|
import cn.jisol.ngame.actions.core.NActionMethod;
|
||||||
|
import cn.jisol.ngame.util.JLoggerUtil;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 裁决员行为 处理裁决
|
* 裁决员行为 处理裁决
|
||||||
@ -17,6 +25,12 @@ public class GRefereeAction {
|
|||||||
//裁决员列表
|
//裁决员列表
|
||||||
public static Map<String, GRefereeClient> REFEREES;
|
public static Map<String, GRefereeClient> REFEREES;
|
||||||
|
|
||||||
|
//裁决员线程列表
|
||||||
|
public static Map<String,Thread> THREADS = new HashMap<>();
|
||||||
|
|
||||||
|
//最大裁决员数量
|
||||||
|
public static int MAX = 10;
|
||||||
|
|
||||||
//获取一个空闲的裁决员
|
//获取一个空闲的裁决员
|
||||||
public static GRefereeClient getFreeReferee(){
|
public static GRefereeClient getFreeReferee(){
|
||||||
|
|
||||||
@ -26,6 +40,10 @@ public class GRefereeAction {
|
|||||||
return REFEREES.get(key);
|
return REFEREES.get(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果没有空闲的裁决客户端则添加
|
||||||
|
addRefereeClient();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -50,6 +68,40 @@ public class GRefereeAction {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//添加裁判客户端
|
||||||
|
public static void addRefereeClient(){
|
||||||
|
|
||||||
|
//生成客户端Id
|
||||||
|
String uuid = IdUtil.simpleUUID();
|
||||||
|
//创建日志类
|
||||||
|
Logger log = JLoggerUtil.file(uuid, "D:\\Jisol\\JisolGame\\headless\\logger", uuid + ".log");
|
||||||
|
|
||||||
|
if(Objects.isNull(log)) return;
|
||||||
|
|
||||||
|
Thread thread = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Process process = Runtime.getRuntime().exec("cmd /c npm run main", null, new File("D:\\Jisol\\JisolGame\\headless"));
|
||||||
|
InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr);
|
||||||
|
String content = br.readLine();
|
||||||
|
while (content != null) {
|
||||||
|
log.log(Level.ALL, content);
|
||||||
|
content = br.readLine();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
thread.start();
|
||||||
|
|
||||||
|
//保存线程
|
||||||
|
THREADS.put(uuid,thread);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public interface GRefereeActionAutoInter{
|
public interface GRefereeActionAutoInter{
|
||||||
GRefereeClient run(GRefereeClient referee);
|
GRefereeClient run(GRefereeClient referee);
|
||||||
}
|
}
|
||||||
|
19
JisolGameServer/Main/src/test/java/TestMain.java
Normal file
19
JisolGameServer/Main/src/test/java/TestMain.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class TestMain {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
Process process = Runtime.getRuntime().exec("cmd /c npm run main",null,new File("D:\\Jisol\\JisolGame\\headless"));
|
||||||
|
InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr);
|
||||||
|
String content = br.readLine();
|
||||||
|
while (content != null) {
|
||||||
|
System.out.println(content);
|
||||||
|
content = br.readLine();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
// const URL = "http://192.168.0.174:7457/web-desktop/web-desktop/index.html"
|
// const URL = "http://192.168.0.174:7457/web-desktop/web-desktop/index.html"
|
||||||
// const express = require("express");
|
// const express = require("express");
|
||||||
// const app = express();
|
// const app = express();
|
||||||
const URL = "http://192.168.0.123:7457/web-desktop/web-desktop/index.html"
|
const URL = "http://192.168.1.23:7456/web-desktop/web-desktop-001/index.html"
|
||||||
|
|
||||||
// const runCocos = () => {
|
// const runCocos = () => {
|
||||||
const { JSDOM,ResourceLoader } = require('jsdom')
|
const { JSDOM,ResourceLoader } = require('jsdom')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user