Files
Workspace/Assets/Modules/ShrinkNetwork.Integration.EventBus/ShrinkNetworkEventRequestOutcome.cs
T

32 lines
1.1 KiB
C#

#nullable enable
using ShrinkEventBus;
namespace ShrinkNetwork.Integration
{
public readonly struct ShrinkNetworkEventRequestOutcome
{
public ShrinkNetworkEventRequestOutcome(int errorCode, string errorMessage, EventResult result, bool isCanceled)
{
ErrorCode = errorCode;
ErrorMessage = errorMessage ?? string.Empty;
Result = result;
IsCanceled = isCanceled;
}
public int ErrorCode { get; }
public string ErrorMessage { get; }
public EventResult Result { get; }
public bool IsCanceled { get; }
public bool IsSuccess => ErrorCode == 0;
internal static ShrinkNetworkEventRequestOutcome FromResponse(ShrinkNetworkEventResultResponse response)
{
return new ShrinkNetworkEventRequestOutcome(
response?.ErrorCode ?? ShrinkRpcErrorCode.InvalidResponse,
response?.ErrorMessage ?? "Network event request returned an invalid response.",
response?.Result ?? EventResult.DEFAULT,
response?.IsCanceled ?? false);
}
}
}