[server] Add ErrorMessage class.
This commit is contained in:
parent
fa9335602e
commit
4a01a6ecbd
2 changed files with 37 additions and 0 deletions
|
@ -45,6 +45,7 @@
|
||||||
<Compile Include="PixelMessage.cs" />
|
<Compile Include="PixelMessage.cs" />
|
||||||
<Compile Include="PixelMessages\HandshakeRequestMessage.cs" />
|
<Compile Include="PixelMessages\HandshakeRequestMessage.cs" />
|
||||||
<Compile Include="PixelMessages\ResetMessage.cs" />
|
<Compile Include="PixelMessages\ResetMessage.cs" />
|
||||||
|
<Compile Include="PixelMessages\ErrorMessage.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
36
PixelHub-Server/PixelHub/PixelMessages/ErrorMessage.cs
Normal file
36
PixelHub-Server/PixelHub/PixelMessages/ErrorMessage.cs
Normal 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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue