Browse Source

[server] Add ErrorMessage class.

master
Starbeamrainbowlabs 4 years ago
parent
commit
4a01a6ecbd
2 changed files with 37 additions and 0 deletions
  1. +1
    -0
      PixelHub-Server/PixelHub/PixelHub.csproj
  2. +36
    -0
      PixelHub-Server/PixelHub/PixelMessages/ErrorMessage.cs

+ 1
- 0
PixelHub-Server/PixelHub/PixelHub.csproj 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>


+ 36
- 0
PixelHub-Server/PixelHub/PixelMessages/ErrorMessage.cs 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()
{
}
}
}