🐛 xunyou_testspeed_ex

This commit is contained in:
Aigio Liu
2024-02-28 20:33:42 +08:00
parent 541399f011
commit 5bbddf86cd
2 changed files with 52 additions and 57 deletions
@@ -16,11 +16,6 @@ partial class XunYouSDK // 20.接口 xunyou_testspeed_ex
int server,
TestSpeedCallback callback)
{
if (server == 0)
{
return TestSpeed(gameid, area, callback);
}
int testSpeedCode = int.MinValue;
unsafe
{
@@ -38,7 +33,7 @@ partial class XunYouSDK // 20.接口 xunyou_testspeed_ex
return result;
}
var xunyou_callback = (delegate* unmanaged[Stdcall]<XunYouSpeedNotifyState, SpeedCallbackInfo*, int>)Marshal.GetFunctionPointerForDelegate(testSpeedCallback = TestSpeedCallback_Wrapper);
testSpeedCode = xunyou_testspeed(gameid, area, xunyou_callback);
testSpeedCode = xunyou_testspeed_ex(gameid, area, server, xunyou_callback);
}
return (XunYouTestSpeedCode)testSpeedCode;
@@ -14,60 +14,60 @@ partial class XunYouSDK // 7.接口 xunyou_testspeed
/// <returns></returns>
public delegate int TestSpeedCallback(SpeedCallbackWrapper m);
/// <summary>
/// 获取指定游戏某分区的测速。
/// </summary>
/// <param name="gameid">游戏 id,由迅游给出明确值。</param>
/// <param name="area">游戏分区 id ,由游戏给出区服名和 id 对照表。</param>
/// <param name="callback">测速回调函数。</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static XunYouTestSpeedCode TestSpeed(int gameid,
int area,
TestSpeedCallback callback)
{
int testSpeedCode = int.MinValue;
unsafe
{
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
int TestSpeedCallback_Wrapper(XunYouSpeedNotifyState state, SpeedCallbackInfo* info)
{
var info_ = Marshal.PtrToStructure<SpeedCallbackInfo>((nint)info);
var result = callback(new SpeedCallbackWrapper
{
Struct = info_,
State = state,
Code = (XunYouTestSpeedCode)testSpeedCode,
ErrorDesc = info_.GetErrorDescString(),
});
return result;
}
var xunyou_callback = (delegate* unmanaged[Stdcall]<XunYouSpeedNotifyState, SpeedCallbackInfo*, int>)Marshal.GetFunctionPointerForDelegate(testSpeedCallback = TestSpeedCallback_Wrapper);
testSpeedCode = xunyou_testspeed(gameid, area, xunyou_callback);
}
///// <summary>
///// 获取指定游戏某分区的测速。
///// </summary>
///// <param name="gameid">游戏 id,由迅游给出明确值。</param>
///// <param name="area">游戏分区 id ,由游戏给出区服名和 id 对照表。</param>
///// <param name="callback">测速回调函数。</param>
///// <returns></returns>
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
//public static XunYouTestSpeedCode TestSpeed(int gameid,
// int area,
// TestSpeedCallback callback)
//{
// int testSpeedCode = int.MinValue;
// unsafe
// {
// [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
// int TestSpeedCallback_Wrapper(XunYouSpeedNotifyState state, SpeedCallbackInfo* info)
// {
// var info_ = Marshal.PtrToStructure<SpeedCallbackInfo>((nint)info);
// var result = callback(new SpeedCallbackWrapper
// {
// Struct = info_,
// State = state,
// Code = (XunYouTestSpeedCode)testSpeedCode,
// ErrorDesc = info_.GetErrorDescString(),
// });
// return result;
// }
// var xunyou_callback = (delegate* unmanaged[Stdcall]<XunYouSpeedNotifyState, SpeedCallbackInfo*, int>)Marshal.GetFunctionPointerForDelegate(testSpeedCallback = TestSpeedCallback_Wrapper);
// testSpeedCode = xunyou_testspeed(gameid, area, xunyou_callback);
// }
return (XunYouTestSpeedCode)testSpeedCode;
}
// return (XunYouTestSpeedCode)testSpeedCode;
//}
/// <summary>
/// 获取指定游戏某分区的测速。
/// </summary>
/// <param name="gameid">游戏 id,由迅游给出明确值。</param>
/// <param name="area">游戏分区 id ,由游戏给出区服名和 id 对照表。</param>
/// <returns></returns>
/// <exception cref="NotSupportedException"></exception>
public static IAsyncEnumerable<SpeedCallbackWrapper> TestSpeed(int gameid, int area)
{
// 异步迭代器版本,用于 Ipc 调用,封装回调函数
// 注意配合停止测试接口
throw new NotSupportedException();
}
///// <summary>
///// 获取指定游戏某分区的测速。
///// </summary>
///// <param name="gameid">游戏 id,由迅游给出明确值。</param>
///// <param name="area">游戏分区 id ,由游戏给出区服名和 id 对照表。</param>
///// <returns></returns>
///// <exception cref="NotSupportedException"></exception>
//public static IAsyncEnumerable<SpeedCallbackWrapper> TestSpeed(int gameid, int area)
//{
// // 异步迭代器版本,用于 Ipc 调用,封装回调函数
// // 注意配合停止测试接口
// throw new NotSupportedException();
//}
[LibraryImport(libraryName)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
private static unsafe partial int xunyou_testspeed(int gameid,
int area,
delegate* unmanaged[Stdcall]<XunYouSpeedNotifyState, SpeedCallbackInfo*, int> callback = null);
//[LibraryImport(libraryName)]
//[UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])]
//private static unsafe partial int xunyou_testspeed(int gameid,
// int area,
// delegate* unmanaged[Stdcall]<XunYouSpeedNotifyState, SpeedCallbackInfo*, int> callback = null);
/// <summary>
/// 获取测速失败描述字符串