diff --git a/src/client/NP/NPClient.cs b/src/client/NP/NPClient.cs
index 960f5cf..347cedd 100644
--- a/src/client/NP/NPClient.cs
+++ b/src/client/NP/NPClient.cs
@@ -34,6 +34,11 @@ namespace NPSharp.NP
_log = LogManager.GetLogger("NPClient");
}
+ ///
+ /// The internal RPC client.
+ ///
+ public RPCClientStream RPCClient { get { return _rpc; } }
+
///
/// The assigned NP user ID. Will be set on successful authentication.
///
@@ -137,6 +142,33 @@ namespace NPSharp.NP
_rpc.Send(new AuthenticateWithTokenMessage {Token = token});
return await tcs.Task;
+ }
+
+ ///
+ /// Authenticates this connection via a platform-specific license key. This may very well include ""
+ /// if the server chooses to allow anonymous logon.
+ ///
+ /// The license key to use for authentication
+ /// True if the login succeeded, otherwise false.
+ public async Task AuthenticateWithLicenseKey(string key)
+ {
+ var tcs = new TaskCompletionSource();
+
+ _rpc.AttachHandlerForNextMessage(packet =>
+ {
+ var result = packet as AuthenticateResultMessage;
+ if (result == null)
+ return;
+
+ if (result.Result != 0)
+ tcs.SetResult(false);
+ LoginId = result.NPID;
+ SessionToken = result.SessionToken;
+ tcs.SetResult(true);
+ });
+ _rpc.Send(new AuthenticateWithKeyMessage { LicenseKey = key });
+
+ return await tcs.Task;
}
// TODO: Try to use an exception for failed action instead