1
0
Fork 0
This repository has been archived on 2019-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Galactic_Colors_Control/Galactic Colors Control Common/Protocol/ResultData.cs

50 lines
1.4 KiB
C#

namespace Galactic_Colors_Control_Common.Protocol
{
public enum ResultTypes { Error, OK }
/// <summary>
/// Server to Client Result from RequestData
/// </summary>
public class ResultData : Data
{
public int id; //Client Side Autoindent
public ResultTypes type;
public string[] result;
public ResultData(int Id, ResultTypes Type, string[] Result = null)
{
id = Id;
type = Type;
result = Result;
}
public ResultData(int Id, RequestResult Result)
{
id = Id;
type = Result.type;
result = Result.result;
}
public ResultData(ref byte[] bytes)
{
id = Binary.ToInt(ref bytes);
type = (ResultTypes)Binary.ToInt(ref bytes);
result = Binary.ToStringArray(ref bytes);
}
public override byte[] ToBytes()
{
return Binary.AddBytes(Binary.FromInt((int)DataType.Result), Binary.FromInt(id), Binary.FromInt((int)type), Binary.FromStringArray(result));
}
public override string ToSmallString()
{
return type.ToString() + "|" + Common.ArrayToString(result);
}
public override string ToLongString()
{
return "Result : " + type.ToString() + "|" + Common.ArrayToString(result) + "|" + id;
}
}
}