37 lines
937 B
C#
37 lines
937 B
C#
using System;
|
|
using System.Text;
|
|
|
|
namespace PixelHub.Server.PixelMessages
|
|
{
|
|
public class ErrorMessage : PixelMessage
|
|
{
|
|
public uint ErrorCode = 0;
|
|
|
|
public string Message = string.Empty;
|
|
|
|
public override byte[] Payload {
|
|
get {
|
|
byte[] rawErrorCode = BitConverter.GetBytes(ErrorCode);
|
|
byte[] rawErrorMessage = Encoding.UTF8.GetBytes(Message);
|
|
|
|
byte[] result = new byte[rawErrorCode.Length + rawErrorMessage.Length];
|
|
Buffer.BlockCopy(rawErrorCode, 0, result, 0, rawErrorCode.Length);
|
|
Buffer.BlockCopy(rawErrorMessage, 0, result, rawErrorCode.Length, rawErrorMessage.Length);
|
|
|
|
return result;
|
|
}
|
|
protected set {
|
|
byte[] rawErrorCode = new byte[sizeof(uint)];
|
|
byte[] rawErrorMessage = new byte[value.Length - sizeof(uint)];
|
|
ErrorCode = BitConverter.ToUInt32(rawErrorCode, 0);
|
|
Message = new string(Encoding.UTF8.GetChars(rawErrorMessage));
|
|
}
|
|
}
|
|
|
|
public ErrorMessage()
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|