Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ReconnectClient #22

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Api/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,25 @@ public async Task<bool> Logout()
return resultJson;
}

/// <summary>
/// Reconnects the provided client
/// </summary>
/// <param name="macAddress">The MAC address of client to reconnect</param>
/// <returns>True if the reconnect was successful or False if it failed</returns>
public async Task<bool> ReconnectClient(string macAddress)
{
string payload = JsonConvert.SerializeObject(new
{
cmd = "kick-sta",
mac = macAddress
});

var resultString = await EnsureAuthenticatedPostRequest(new Uri(BaseUri, $"/api/s/{SiteId}/cmd/stamgr"), payload);
var resultJson = JsonConvert.DeserializeObject<Responses.ResponseEnvelope<Responses.BaseResponse>>(resultString);

return resultJson.meta.ResultCode.Equals("ok", StringComparison.InvariantCultureIgnoreCase);
}

#endregion
}
}
7 changes: 7 additions & 0 deletions Api/KoenZomers.UniFi.Api.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.