[server] Add ErrorMessage class.

This commit is contained in:
Starbeamrainbowlabs 2017-03-04 14:47:28 +00:00
parent fa9335602e
commit 4a01a6ecbd
2 changed files with 37 additions and 0 deletions

View file

@ -45,6 +45,7 @@
<Compile Include="PixelMessage.cs" />
<Compile Include="PixelMessages\HandshakeRequestMessage.cs" />
<Compile Include="PixelMessages\ResetMessage.cs" />
<Compile Include="PixelMessages\ErrorMessage.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

View file

@ -0,0 +1,36 @@
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);
Message = Encoding.UTF8.
}
}
public ErrorMessage()
{
}
}
}