mirror of https://github.com/icedream/npsharp.git
add validateticket call
parent
612fd05702
commit
ac7e1b1a78
|
@ -161,7 +161,12 @@ namespace NPSharp.NP
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (result.Result != 0)
|
if (result.Result != 0)
|
||||||
|
{
|
||||||
tcs.SetResult(false);
|
tcs.SetResult(false);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LoginId = result.NPID;
|
LoginId = result.NPID;
|
||||||
SessionToken = result.SessionToken;
|
SessionToken = result.SessionToken;
|
||||||
tcs.SetResult(true);
|
tcs.SetResult(true);
|
||||||
|
@ -171,6 +176,30 @@ namespace NPSharp.NP
|
||||||
return await tcs.Task;
|
return await tcs.Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> ValidateTicket(uint clientIP, ulong npID, byte[] ticket)
|
||||||
|
{
|
||||||
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
|
_rpc.AttachHandlerForNextMessage(packet =>
|
||||||
|
{
|
||||||
|
var result = packet as AuthenticateValidateTicketResultMessage;
|
||||||
|
if (result == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (result.Result != 0)
|
||||||
|
{
|
||||||
|
tcs.SetResult(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tcs.SetResult(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_rpc.Send(new AuthenticateValidateTicketMessage { ClientIP = clientIP, Ticket = ticket, NPID = npID });
|
||||||
|
|
||||||
|
return await tcs.Task;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Try to use an exception for failed action instead
|
// TODO: Try to use an exception for failed action instead
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Uploads a user file.
|
/// Uploads a user file.
|
||||||
|
|
Loading…
Reference in New Issue