From 9fcd5d3c3e1d3f851851f127289ffb5a806337b7 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 12 Sep 2024 14:35:44 +0800 Subject: [PATCH] =?UTF-8?q?WebApi=20=E6=A3=80=E6=9F=A5=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=92=8C=E8=8E=B7=E5=8F=96=E6=9C=8D=E5=8A=A1=E5=99=A8IP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AxibugEmuOnline.Web/Common/Config.cs | 6 ++++ .../Controllers/ApiController.cs | 24 +++++++++++++ README_WEBAPI.md | 35 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/AxibugEmuOnline.Web/Common/Config.cs b/AxibugEmuOnline.Web/Common/Config.cs index 8e303e7..9c6caae 100644 --- a/AxibugEmuOnline.Web/Common/Config.cs +++ b/AxibugEmuOnline.Web/Common/Config.cs @@ -16,6 +16,9 @@ namespace AxibugEmuOnline.Web.Common public string DBPwd{get;set;} public string RomDir{get;set;} public string ImageDir { get; set; } + public string ServerIp { get; set; } + public ushort ServerPort { get; set; } + public string ClientVersion { get; set; } } @@ -38,6 +41,9 @@ namespace AxibugEmuOnline.Web.Common DBName = "DBName", RomDir = "./Rom", ImageDir = "./Img", + ServerIp = "127.0.0.1", + ServerPort = 10001, + ClientVersion = "0.0.0.1" }; string jsonString = JsonSerializer.Serialize(sampleCfg, new JsonSerializerOptions() diff --git a/AxibugEmuOnline.Web/Controllers/ApiController.cs b/AxibugEmuOnline.Web/Controllers/ApiController.cs index a9c3b7c..087a2e4 100644 --- a/AxibugEmuOnline.Web/Controllers/ApiController.cs +++ b/AxibugEmuOnline.Web/Controllers/ApiController.cs @@ -13,6 +13,20 @@ namespace AxibugEmuOnline.Web.Controllers _logger = logger; } + [HttpGet] + public JsonResult CheckStandInfo(int platform, string version) + { + Resp_CheckStandInfo resp = new Resp_CheckStandInfo() + { + needUpdateClient = 0, + clientVersion = Config.cfg.ClientVersion, + serverIp = Config.cfg.ServerIp, + serverPort = Config.cfg.ServerPort, + downLoadUrl = "" + }; + return new JsonResult(resp); + } + [HttpGet] public JsonResult NesRomList(string SearchKey,int Ptype,int GType,int Page, int PageSize) { @@ -117,6 +131,16 @@ namespace AxibugEmuOnline.Web.Controllers ALLINONE, } + class Resp_CheckStandInfo + { + public int needUpdateClient { get; set; } + public string serverIp { get; set; } + public ushort serverPort { get; set; } + public string clientVersion { get; set; } + public string downLoadUrl { get; set; } + } + + class Resp_GameList { public int page { get; set; } diff --git a/README_WEBAPI.md b/README_WEBAPI.md index 793c50a..7b8b69b 100644 --- a/README_WEBAPI.md +++ b/README_WEBAPI.md @@ -2,6 +2,41 @@ 这里说明,WebApi类的接口 +### 基本信息检查 + +``` +{WebHost}/api/NesRomList?platform=<平台编号>&version=<版本> +``` +Request: + +``` +http://emu.axibug.com/api/CheckStandInfo?platform=1&version=1.0.0.0 +``` + +Response: + +``` +{ + "needUpdateClient": 0, + "serverIp": "139.186.160.243", + "serverPort": 10492, + "clientVersion": "0.0.0.1", + "downLoadUrl": "" +} +``` + +序列化C#实体类示例 + +``` +class Resp_CheckStandInfo +{ + public int needUpdateClient { get; set; } + public string serverIp { get; set; } + public ushort serverPort { get; set; } + public string clientVersion { get; set; } + public string downLoadUrl { get; set; } +} +``` ### Nes游戏列表