Add online matching testing code
Add event download code
This commit is contained in:
parent
80b69400d5
commit
a5fea98d59
@ -4,4 +4,5 @@
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Fcol/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Incom/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pcol/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Respone/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Respone/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tenpo/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@ -50,10 +50,6 @@
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</Content>
|
||||
<None Remove="GC-local-server-rewrite.exe.config.xml" />
|
||||
<None Include="GC-local-server-rewrite.exe.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</None>
|
||||
<None Remove="db\music4MAX.db3" />
|
||||
<Content Include="db\music4MAX.db3">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="AvatarCount" value="323"/>
|
||||
<add key="NavigatorCount" value="94"/>
|
||||
<add key="ItemCount" value="21"/>
|
||||
<add key="SkinCount" value="21"/>
|
||||
<add key="SeCount" value="26"/>
|
||||
<add key="TitleCount" value="5273"/>
|
||||
<add key="MusicDBName" value="music4MAX465.db3"/>
|
||||
<add key="ServerIp" value="127.0.0.1"/>
|
||||
</appSettings>
|
||||
</configuration>
|
@ -32,7 +32,7 @@ internal class Program
|
||||
Terminal.Flush();
|
||||
|
||||
Console.WriteLine("Press any key to exit.");
|
||||
WaitForKeypress();
|
||||
Console.ReadKey(true);
|
||||
}
|
||||
|
||||
private static void InitializeLogging()
|
||||
@ -67,7 +67,7 @@ internal class Program
|
||||
// Be sure to run in parallel.
|
||||
await Task.Yield();
|
||||
|
||||
"Press any key to stop the web server.".Info(nameof(Program));
|
||||
"Press x to stop the web server.".Info(nameof(Program));
|
||||
WaitForKeypress();
|
||||
"Stopping...".Info(nameof(Program));
|
||||
cancel();
|
||||
@ -78,12 +78,17 @@ internal class Program
|
||||
/// </summary>
|
||||
private static void WaitForKeypress()
|
||||
{
|
||||
while (Console.KeyAvailable)
|
||||
{
|
||||
Console.ReadKey(true);
|
||||
}
|
||||
ConsoleKeyInfo consoleKeyInfo;
|
||||
|
||||
Console.ReadKey(true);
|
||||
do
|
||||
{
|
||||
while (Console.KeyAvailable == false)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
|
||||
consoleKeyInfo = Console.ReadKey(true);
|
||||
} while (consoleKeyInfo.Key != ConsoleKey.X);
|
||||
}
|
||||
|
||||
private static void LogConfigValues()
|
||||
|
@ -4,7 +4,7 @@ namespace GCLocalServerRewrite.common;
|
||||
|
||||
public static class Configs
|
||||
{
|
||||
public const bool USE_FILE_CACHE = false;
|
||||
public const bool USE_FILE_CACHE = true;
|
||||
|
||||
public const string ROOT_CA_CN = "Taito Arcade Machine CA";
|
||||
|
||||
@ -126,6 +126,8 @@ public static class Configs
|
||||
|
||||
public const string RANK_STATUS_XPATH = $"{ROOT_XPATH}/ranking_status";
|
||||
|
||||
public const string ONLINE_MATCHING_XPATH = $"{ROOT_XPATH}/online_matching/record";
|
||||
|
||||
public const int FIRST_CONFIG_PCOL1 = 0;
|
||||
public const int SECOND_CONFIG_PCOL1 = 1;
|
||||
public const int CONFIG_PCOL2 = 0;
|
||||
@ -159,6 +161,7 @@ public static class Configs
|
||||
public const string DEFAULT_SERVER_IP = "127.0.0.1";
|
||||
public const string DEFAULT_RELAY_SERVER = "127.0.0.1";
|
||||
public const int DEFAULT_RELAY_PORT = 54321;
|
||||
public const string DEFAULT_EVENT_FOLDER = "event";
|
||||
|
||||
public static readonly IReadOnlyList<int> DEFAULT_UNLOCKABLE_SONGS = new[]
|
||||
{
|
||||
|
@ -30,6 +30,9 @@ public interface IAppSettings
|
||||
|
||||
[Option(DefaultValue = Configs.DEFAULT_SERVER_IP)]
|
||||
string ServerIp { get; }
|
||||
|
||||
[Option(DefaultValue = Configs.DEFAULT_EVENT_FOLDER)]
|
||||
string EventFolder { get; }
|
||||
|
||||
[Option(DefaultValue = Configs.DEFAULT_RELAY_SERVER)]
|
||||
string RelayServer { get; }
|
||||
|
@ -6,9 +6,10 @@
|
||||
"SeCount": 26,
|
||||
"TitleCount": 5530,
|
||||
"CardDbName": "card.db3",
|
||||
"MusicDbName": "music471.db3",
|
||||
"MusicDbName": "music471omni.db3",
|
||||
"ServerIp": "127.0.0.1",
|
||||
"RelayServer": "26.56.10.224",
|
||||
"EventFolder": "event",
|
||||
"RelayServer": "127.0.0.1",
|
||||
"RelayPort": 54321,
|
||||
"UnlockableSongIds": [
|
||||
11, 13, 149, 273, 291, 320, 321, 371, 378, 384, 464, 471, 474, 475, 492, 494, 498, 520,
|
||||
@ -69,7 +70,7 @@
|
||||
"FileName": "/event_unlock_20201125.cmp",
|
||||
"NotBeforeUnixTime": 1335677127,
|
||||
"NotAfterUnixTime": 1966397127,
|
||||
"Md5": "623b0f10125cbe19c5394d992930ae8c",
|
||||
"Md5": "534a253e3de8360c2beff49a5f120105",
|
||||
"Index": 8
|
||||
}
|
||||
]
|
||||
|
@ -18,6 +18,8 @@ public class CardServiceController : WebApiController
|
||||
private readonly SQLiteConnection cardSqLiteConnection;
|
||||
private readonly SQLiteConnection musicSqLiteConnection;
|
||||
|
||||
private static Dictionary<long, OnlineMatchingEntry> OnlineMatchingEntries = new();
|
||||
|
||||
public CardServiceController()
|
||||
{
|
||||
cardSqLiteConnection = DatabaseHelper.ConnectDatabase(Configs.SETTINGS.CardDbName);
|
||||
@ -42,7 +44,7 @@ public class CardServiceController : WebApiController
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(cmdType), cmdType, $"Cmd type is unknown!\n Data is {xmlData}");
|
||||
}
|
||||
|
||||
|
||||
var command = (Command)cmdType;
|
||||
|
||||
return command switch
|
||||
@ -73,9 +75,9 @@ public class CardServiceController : WebApiController
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(type), type, "Card request type is unknown!");
|
||||
}
|
||||
|
||||
|
||||
var requestType = (CardRequestType)type;
|
||||
|
||||
|
||||
$"Getting card request, type is {requestType}".Info();
|
||||
|
||||
switch (requestType)
|
||||
@ -172,8 +174,8 @@ public class CardServiceController : WebApiController
|
||||
{
|
||||
return ConstructResponse(TotalTrophy(cardId));
|
||||
}
|
||||
case CardRequestType.SessionStart:
|
||||
case CardRequestType.SessionGet:
|
||||
case CardRequestType.StartSession:
|
||||
case CardRequestType.GetSession:
|
||||
{
|
||||
return ConstructResponse(GetSession(cardId, mac));
|
||||
}
|
||||
@ -184,19 +186,19 @@ public class CardServiceController : WebApiController
|
||||
|
||||
case CardRequestType.WriteCard:
|
||||
{
|
||||
$"Card Request data is {xmlData}".Info();
|
||||
$"Card Write data is {xmlData}".Info();
|
||||
Write<Card>(cardId, xmlData);
|
||||
return ConstructResponse(xmlData);
|
||||
}
|
||||
case CardRequestType.WriteCardDetail:
|
||||
{
|
||||
$"Card Request data is {xmlData}".Info();
|
||||
$"Card Detail Write data is {xmlData}".Info();
|
||||
WriteCardDetail(cardId, xmlData);
|
||||
return ConstructResponse(xmlData);
|
||||
}
|
||||
case CardRequestType.WriteCardBData:
|
||||
{
|
||||
$"Card Request data is {xmlData}".Info();
|
||||
$"Card BData Write data is {xmlData}".Info();
|
||||
Write<CardBData>(cardId, xmlData);
|
||||
WriteCardPlayCount(cardId);
|
||||
return ConstructResponse(xmlData);
|
||||
@ -212,17 +214,26 @@ public class CardServiceController : WebApiController
|
||||
case CardRequestType.WriteUnlockKeynum:
|
||||
case CardRequestType.WriteSoundEffect:
|
||||
{
|
||||
$"Card Request data is {xmlData}".Info();
|
||||
$"Card Write data is {xmlData}".Info();
|
||||
return ConstructResponse(xmlData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region OnlineMatching
|
||||
|
||||
case CardRequestType.StartOnlineMatching:
|
||||
{
|
||||
$"Start Online Matching, data is {xmlData}".Info();
|
||||
return ConstructResponse(StartOnlineMatching(cardId, xmlData));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(requestType), requestType, "Request type not captured, should never happen!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region ReadImplementation
|
||||
|
||||
private string Card(long cardId, out ReturnCode returnCode)
|
||||
@ -404,7 +415,7 @@ public class CardServiceController : WebApiController
|
||||
|
||||
private static string ConstructResponse(string xml, ReturnCode returnCode = ReturnCode.Ok)
|
||||
{
|
||||
var returnCodeInt = (int)returnCode;
|
||||
var returnCodeInt = (int)returnCode;
|
||||
if (returnCodeInt == 1)
|
||||
{
|
||||
return $"{returnCodeInt}\n" +
|
||||
@ -534,7 +545,7 @@ public class CardServiceController : WebApiController
|
||||
$"Updated card play count, current count is {data.PlayCount}".Info();
|
||||
}
|
||||
|
||||
private void WriteCardDetail(long cardId, string xmlData)
|
||||
private void WriteCardDetail(long cardId, string xmlData)
|
||||
{
|
||||
var result = cardSqLiteConnection.Table<CardDetail>()
|
||||
.Where(detail => detail.CardId == cardId);
|
||||
@ -588,6 +599,44 @@ public class CardServiceController : WebApiController
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnlineMatchingImplementation
|
||||
|
||||
private static string StartOnlineMatching(long cardId, string xmlData)
|
||||
{
|
||||
var reader = new ChoXmlReader<OnlineMatchingEntry>(new StringReader(xmlData)).WithXPath(Configs.DATA_XPATH);
|
||||
var entry = reader.Read();
|
||||
|
||||
/*var fake = entry.CopyPropertiesToNew<OnlineMatchingEntry>();
|
||||
fake.MachineId--;
|
||||
fake.MatchingId = 0xB16B00B5;
|
||||
fake.EntryStart = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
fake.CardId = cardId - 1;
|
||||
fake.AvatarId--;
|
||||
fake.PlayerName = "FAKE";
|
||||
fake.EntryNo = 0x4B1D;
|
||||
fake.TitleId--;
|
||||
fake.MatchingTimeout = 90;
|
||||
fake.MatchingRemainingTime = 89;
|
||||
fake.MatchingWaitTime = 1;
|
||||
fake.Status = 1;
|
||||
OnlineMatchingEntries[fake.CardId] = fake;*/
|
||||
|
||||
entry.CardId = cardId;
|
||||
entry.MatchingId = 0xB16B00B5;
|
||||
entry.EntryNo = 0;
|
||||
entry.EntryStart = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
entry.MatchingTimeout = 90 * 1000;
|
||||
entry.MatchingRemainingTime = 89 * 1000;
|
||||
entry.MatchingWaitTime = 1;
|
||||
entry.Status = 1;
|
||||
entry.Dump().Info();
|
||||
OnlineMatchingEntries[cardId] = entry;
|
||||
|
||||
return GenerateRecordsXml(OnlineMatchingEntries.Values.ToList(), Configs.ONLINE_MATCHING_XPATH);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private enum CardRequestType
|
||||
{
|
||||
// Read data
|
||||
@ -613,8 +662,8 @@ public class CardServiceController : WebApiController
|
||||
ReadTotalTrophy = 8468,
|
||||
|
||||
// Sessions
|
||||
SessionGet = 401,
|
||||
SessionStart = 402,
|
||||
GetSession = 401,
|
||||
StartSession = 402,
|
||||
|
||||
// Write data
|
||||
WriteCard = 771,
|
||||
@ -628,7 +677,10 @@ public class CardServiceController : WebApiController
|
||||
WriteCoin = 980,
|
||||
WriteSkin = 933,
|
||||
WriteUnlockKeynum = 1020,
|
||||
WriteSoundEffect = 8969
|
||||
WriteSoundEffect = 8969,
|
||||
|
||||
// Online matching
|
||||
StartOnlineMatching = 8705
|
||||
}
|
||||
|
||||
private enum Command
|
||||
@ -645,12 +697,12 @@ public class CardServiceController : WebApiController
|
||||
/// 処理は正常に完了しました in debug string
|
||||
/// </summary>
|
||||
Ok = 1,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 未登録のカードです in debug string
|
||||
/// </summary>
|
||||
CardNotRegistered = 23,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 再発行予約がありません in debug string
|
||||
/// </summary>
|
||||
|
@ -15,6 +15,8 @@ namespace GCLocalServerRewrite.controllers;
|
||||
|
||||
public class ServerController : WebApiController
|
||||
{
|
||||
private static readonly string DataUrl = $"https://{Configs.SETTINGS.ServerIp}/{Configs.STATIC_FOLDER}/{Configs.SETTINGS.EventFolder}";
|
||||
|
||||
[Route(HttpVerbs.Get, "/certify.php")]
|
||||
public string Certify([QueryData] NameValueCollection parameters)
|
||||
{
|
||||
@ -99,12 +101,13 @@ public class ServerController : WebApiController
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var data = responseList[i];
|
||||
dataString.Append($"{i},{data.FileName},{data.NotBeforeUnixTime},{data.NotAfterUnixTime},{data.Md5},{data.Index}");
|
||||
var fileUrl = data.FileName.StartsWith("/") ? $"{DataUrl}{data.FileName}" : $"{DataUrl}/{data.FileName}";
|
||||
dataString.Append($"{i},{fileUrl},{data.NotBeforeUnixTime},{data.NotAfterUnixTime},{data.Md5},{data.Index}");
|
||||
dataString.Append('\n');
|
||||
}
|
||||
|
||||
return $"count={count}\n" +
|
||||
"nexttime=0\n" +
|
||||
"nexttime=1\n" +
|
||||
dataString.ToString().TrimEnd('\n');
|
||||
}
|
||||
|
||||
|
87
GC-local-server-rewrite/models/OnlineMatchingEntry.cs
Normal file
87
GC-local-server-rewrite/models/OnlineMatchingEntry.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System.Xml.Serialization;
|
||||
using ChoETL;
|
||||
|
||||
namespace GCLocalServerRewrite.models;
|
||||
|
||||
public class OnlineMatchingEntry: Record
|
||||
{
|
||||
[XmlElement(ElementName = "machine_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "machine_id")]
|
||||
public long MachineId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "event_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "event_id")]
|
||||
public long EventId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "matching_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "matching_id")]
|
||||
public long MatchingId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "entry_no")]
|
||||
[ChoXmlElementRecordField(FieldName = "entry_no")]
|
||||
public long EntryNo { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "entry_start")]
|
||||
[ChoXmlElementRecordField(FieldName = "entry_start")]
|
||||
public string EntryStart { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
[XmlElement(ElementName = "status")]
|
||||
[ChoXmlElementRecordField(FieldName = "status")]
|
||||
public long Status { get; set; } = 1;
|
||||
|
||||
[XmlElement(ElementName = "card_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "card_id")]
|
||||
public long CardId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "player_name")]
|
||||
[ChoXmlElementRecordField(FieldName = "player_name")]
|
||||
public string PlayerName { get; set; } = string.Empty;
|
||||
|
||||
[XmlElement(ElementName = "avatar_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "avatar_id")]
|
||||
public long AvatarId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "title_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "title_id")]
|
||||
public long TitleId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "class_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "class_id")]
|
||||
public long ClassId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "group_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "group_id")]
|
||||
public long GroupId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "tenpo_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "tenpo_id")]
|
||||
public long TenpoId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "tenpo_name")]
|
||||
[ChoXmlElementRecordField(FieldName = "tenpo_name")]
|
||||
public string TenpoName { get; set; } = "1337";
|
||||
|
||||
[XmlElement(ElementName = "pref_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "pref_id")]
|
||||
public long PrefId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "pref")]
|
||||
[ChoXmlElementRecordField(FieldName = "pref")]
|
||||
public string Pref { get; set; } = "nesys";
|
||||
|
||||
[XmlElement(ElementName = "message_id")]
|
||||
[ChoXmlElementRecordField(FieldName = "message_id")]
|
||||
public long MessageId { get; set; }
|
||||
|
||||
[XmlElement(ElementName = "matching_timeout")]
|
||||
[ChoXmlElementRecordField(FieldName = "matching_timeout")]
|
||||
public long MatchingTimeout { get; set; } = 99;
|
||||
|
||||
[XmlElement(ElementName = "matching_wait_time")]
|
||||
[ChoXmlElementRecordField(FieldName = "matching_wait_time")]
|
||||
public long MatchingWaitTime { get; set; } = 10;
|
||||
|
||||
[XmlElement(ElementName = "matching_remaining_time")]
|
||||
[ChoXmlElementRecordField(FieldName = "matching_remaining_time")]
|
||||
public long MatchingRemainingTime { get; set; } = 89;
|
||||
}
|
Loading…
Reference in New Issue
Block a user