diff options
Diffstat (limited to 'Impostor-dev/src/Impostor.Api/Innersloth/ServerInfo.cs')
-rw-r--r-- | Impostor-dev/src/Impostor.Api/Innersloth/ServerInfo.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Impostor-dev/src/Impostor.Api/Innersloth/ServerInfo.cs b/Impostor-dev/src/Impostor.Api/Innersloth/ServerInfo.cs new file mode 100644 index 0000000..7785823 --- /dev/null +++ b/Impostor-dev/src/Impostor.Api/Innersloth/ServerInfo.cs @@ -0,0 +1,37 @@ +using System.IO; +using System.Net; + +namespace Impostor.Api.Innersloth +{ + public class ServerInfo + { + public string Name { get; } + public string Ip { get; } + public ushort Port { get; } + + public ServerInfo(string name, string ip, ushort port) + { + Name = name; + Ip = ip; + Port = port; + } + + public void Serialize(BinaryWriter writer) + { + writer.Write(Name); + writer.Write(IPAddress.Parse(Ip).GetAddressBytes()); + writer.Write(Port); + writer.Write(0); + } + + public static ServerInfo Deserialize(BinaryReader reader) + { + var name = reader.ReadString(); + var ip = new IPAddress(reader.ReadBytes(4)).ToString(); + var port = reader.ReadUInt16(); + var unknown = reader.ReadInt32(); + + return new ServerInfo(name, ip, port); + } + } +}
\ No newline at end of file |