public async Task <bool> AuthenticateAsync(string rconPassword) { QueuedCommandPackets.TryAdd(0, null); using (var packet = new RconPacket(0, 3)) { var bPassword = Encoding.Default.GetBytes(rconPassword); packet._packetWriter.Write(bPassword); await SendAsync(packet.Buffer); } return((await ReceivePacketAsync <RconAuthResultPacket>(0)) .Authenticated); }
public async Task <TPacket> ExecuteCommandAsync <TPacket>(string command) where TPacket : RconPacket { var packetId = Environment.TickCount; QueuedCommandPackets.TryAdd(packetId, null); using (var packet = new RconPacket(packetId, 2)) { var data = Encoding.Default.GetBytes(command); packet._packetWriter.Write(data, 0, data.Length); await SendAsync(packet.Buffer); } return(await ReceivePacketAsync <TPacket>(packetId)); }