BadScript 2
Loading...
Searching...
No Matches
BadConsoleWritePacket.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Text;
4
6
11{
17 public BadConsoleWritePacket(bool isWriteLine, string message)
18 {
19 IsWriteLine = isWriteLine;
20 Message = message;
21 }
22
26 public bool IsWriteLine { get; }
27
31 public string Message { get; }
32
38 public new static BadConsoleWritePacket Deserialize(byte[] data)
39 {
40 bool isWriteLine = data[1] == 1;
41 int messageSize = BitConverter.ToInt32(data, 2);
42
43 string message = Encoding.UTF8.GetString(data, sizeof(int) + 2, messageSize);
44
45 return new BadConsoleWritePacket(isWriteLine, message);
46 }
47
49 public override byte[] Serialize()
50 {
51 List<byte> data = new List<byte>
52 {
53 (byte)BadConsolePacketType.Write,
54 (byte)(IsWriteLine ? 1 : 0),
55 };
56 byte[] message = Encoding.UTF8.GetBytes(Message);
57 data.AddRange(BitConverter.GetBytes(message.Length));
58 data.AddRange(message);
59
60 return data.ToArray();
61 }
62}
BadConsoleWritePacket(bool isWriteLine, string message)
Constructs a new BadConsoleWritePacket instance.
static new BadConsoleWritePacket Deserialize(byte[] data)
Deserializes the Packet.
Contains the network packets for the remote console.