mirror of
https://github.com/milimoe/FunGame-Testing.git
synced 2025-12-05 08:09:04 +00:00
测试 WebSocket 连接
This commit is contained in:
parent
5f41ff32b8
commit
ca07c4d9ff
@ -1,15 +1,3 @@
|
|||||||
using Milimoe.FunGame.Testing.Tests;
|
using Milimoe.FunGame.Testing.Tests;
|
||||||
|
|
||||||
FunGameSimulation.LoadModules();
|
_ = new WebSocketTest();
|
||||||
|
|
||||||
bool printout = true;
|
|
||||||
List<string> strs = FunGameSimulation.StartGame(printout);
|
|
||||||
if (printout == false)
|
|
||||||
{
|
|
||||||
foreach (string str in strs)
|
|
||||||
{
|
|
||||||
Console.WriteLine(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.ReadKey();
|
|
||||||
|
|||||||
@ -10,6 +10,23 @@ namespace Milimoe.FunGame.Testing.Tests
|
|||||||
{
|
{
|
||||||
public class FunGameSimulation
|
public class FunGameSimulation
|
||||||
{
|
{
|
||||||
|
public FunGameSimulation()
|
||||||
|
{
|
||||||
|
LoadModules();
|
||||||
|
|
||||||
|
bool printout = true;
|
||||||
|
List<string> strs = StartGame(printout);
|
||||||
|
if (printout == false)
|
||||||
|
{
|
||||||
|
foreach (string str in strs)
|
||||||
|
{
|
||||||
|
Console.WriteLine(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Character> Characters { get; } = [];
|
public static List<Character> Characters { get; } = [];
|
||||||
public static Dictionary<Character, CharacterStatistics> CharacterStatistics { get; } = [];
|
public static Dictionary<Character, CharacterStatistics> CharacterStatistics { get; } = [];
|
||||||
public static PluginConfig StatsConfig { get; } = new(nameof(FunGameSimulation), nameof(CharacterStatistics));
|
public static PluginConfig StatsConfig { get; } = new(nameof(FunGameSimulation), nameof(CharacterStatistics));
|
||||||
|
|||||||
31
Library/Tests/WebSocketTest.cs
Normal file
31
Library/Tests/WebSocketTest.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Network;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Testing.Tests
|
||||||
|
{
|
||||||
|
public class WebSocketTest
|
||||||
|
{
|
||||||
|
public WebSocketTest()
|
||||||
|
{
|
||||||
|
TaskUtility.NewTask(async () =>
|
||||||
|
{
|
||||||
|
HTTPClient client = await HTTPClient.Connect("localhost", 22223, false, "ws");
|
||||||
|
ArrayList list = [];
|
||||||
|
list.Add(new string[] { "oshima.fungame.fastauto" });
|
||||||
|
list.Add(false);
|
||||||
|
Console.WriteLine(NetworkUtility.JsonSerialize(new SocketObject(Core.Library.Constant.SocketMessageType.Connect, Guid.NewGuid(), list)));
|
||||||
|
await client.Send(Core.Library.Constant.SocketMessageType.Connect, list);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
await Task.Delay(1000);
|
||||||
|
await client.Send(Core.Library.Constant.SocketMessageType.HeartBeat);
|
||||||
|
}
|
||||||
|
}).OnError(Console.WriteLine);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
string str = Console.ReadLine() ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user