From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- .../Impostor.Api/Net/Messages/IMessageWriter.cs | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 Impostor-dev/src/Impostor.Api/Net/Messages/IMessageWriter.cs (limited to 'Impostor-dev/src/Impostor.Api/Net/Messages/IMessageWriter.cs') diff --git a/Impostor-dev/src/Impostor.Api/Net/Messages/IMessageWriter.cs b/Impostor-dev/src/Impostor.Api/Net/Messages/IMessageWriter.cs new file mode 100644 index 0000000..4f6765b --- /dev/null +++ b/Impostor-dev/src/Impostor.Api/Net/Messages/IMessageWriter.cs @@ -0,0 +1,127 @@ +using System; +using System.Net; +using Impostor.Api.Games; + +namespace Impostor.Api.Net.Messages +{ + /// + /// Base message writer. + /// + public interface IMessageWriter : IDisposable + { + public byte[] Buffer { get; } + + public int Length { get; set; } + + public int Position { get; set; } + + public MessageType SendOption { get; } + + /// + /// Writes a boolean to the message. + /// + /// Value to write. + void Write(bool value); + + /// + /// Writes a sbyte to the message. + /// + /// Value to write. + void Write(sbyte value); + + /// + /// Writes a byte to the message. + /// + /// Value to write. + void Write(byte value); + + /// + /// Writes a short to the message. + /// + /// Value to write. + void Write(short value); + + /// + /// Writes an ushort to the message. + /// + /// Value to write. + void Write(ushort value); + + /// + /// Writes an uint to the message. + /// + /// Value to write. + void Write(uint value); + + /// + /// Writes an int to the message. + /// + /// Value to write. + void Write(int value); + + /// + /// Writes a float to the message. + /// + /// Value to write. + void Write(float value); + + /// + /// Writes a string to the message. + /// + /// Value to write. + void Write(string value); + + /// + /// Writes a to the message. + /// + /// Value to write. + void Write(IPAddress value); + + /// + /// Writes an packed int to the message. + /// + /// Value to write. + void WritePacked(int value); + + /// + /// Writes an packed uint to the message. + /// + /// Value to write. + void WritePacked(uint value); + + /// + /// Writes raw bytes to the message. + /// + /// Bytes to write. + void Write(ReadOnlyMemory data); + + /// + /// Writes a game code to the message. + /// + /// Value to write. + void Write(GameCode value); + + void WriteBytesAndSize(byte[] bytes); + + void WriteBytesAndSize(byte[] bytes, int length); + + void WriteBytesAndSize(byte[] bytes, int offset, int length); + + /// + /// Starts a new message. + /// + /// Message flag header. + void StartMessage(byte typeFlag); + + /// + /// Mark the end of the message. + /// + void EndMessage(); + + /// + /// Clear the message writer. + /// + /// New type of the message. + void Clear(MessageType type); + } +} \ No newline at end of file -- cgit v1.1-26-g67d0