29 lines
713 B
C#
29 lines
713 B
C#
using System.Runtime.InteropServices;
|
|
|
|
namespace Meum.Core.Messages;
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct CodeMessage
|
|
{
|
|
// 0xb65d6d - meum in 6-bit ascii encoding
|
|
// 02 - CodeMessage
|
|
private const uint correct_magic = 0xb65d6d01;
|
|
|
|
/// warning: check with <see cref="ThrowIfInvalid"/>
|
|
public uint magic;
|
|
/// warning: can be any int
|
|
public MessageTypeCode type_code;
|
|
|
|
public CodeMessage(MessageTypeCode t)
|
|
{
|
|
magic = correct_magic;
|
|
type_code = t;
|
|
}
|
|
|
|
public void ThrowIfInvalid()
|
|
{
|
|
if(magic != correct_magic)
|
|
throw new Exception($"Invalid CodeMessage magic: {magic}");
|
|
}
|
|
}
|