/// <summary> /// Send the proper authentication packet and parse the response /// </summary> /// <param name="password">Current server password</param> /// <returns>True if the connection has been authenticated; False elsewhere</returns> /// <remarks>This method must be called prior to sending any other command</remarks> /// <exception cref="ArgumentException">Is thrown if <paramref name="password"/> parameter is null or empty</exception> public async Task <bool> AuthenticateAsync(string password) { if (string.IsNullOrEmpty(password)) { throw new ArgumentException("password parameter must be a non null non empty string"); } var authPacket = RconPacket.Create(PacketType.Auth, password); try { var response = await SendPacketAsync(authPacket); } catch (AuthenticationException ex) { return(false); } return(true); }
public Task <string> ExecuteCommandAsync(string command, bool isMultiPacketResponse = false) { return(SendPacketAsync(RconPacket.Create(PacketType.ExecCommand, command), isMultiPacketResponse)); }