private static void GetTicketCallbackImpl(IntPtr ptr, Result result, ref string data) { GCHandle h = GCHandle.FromIntPtr(ptr); GetTicketHandler callback = (GetTicketHandler)h.Target; h.Free(); callback(result, ref data); }
/// <summary> /// Get the signed app ticket for the current user. /// The structure of the ticket is: <c>version.signature.base64encodedjson</c>, so you should split the string by the /// <c>.</c> character. /// Ensure that the <c>version</c> matches the current version. The <c>signature</c> is used to verify the ticket using /// the libsodium library of your choice, /// and the <c>base64encodedjson</c> is what you can transform after verification. It contains: /// <list type="bullet"> /// <item>the application id tied to the ticket</item> /// <item>the user's user id</item> /// <item>a timestamp for the ticket</item> /// <item>the list of the user's <see cref="Store.Entitlement" />s for the application id</item> /// </list> /// These values can be accessed by transforming the string into a /// <a href="https://discord.com/developers/docs/game-sdk/applications#data-models-signedappticket-struct">SignedAppTicket</a> /// with your application's private key. The ticket is signed using /// <a href="https://github.com/jedisct1/libsodium">libsodium</a> which should be available for any programming /// language. Here's a /// <a href="https://download.libsodium.org/doc/bindings_for_other_languages">list of available libraries</a>. /// <para> /// Note that both the public key you receive from Discord and the signature within the app ticket from the SDK /// are both in hex, and will need to be converted to <see cref="byte" />[] before use with libsodium. /// </para> /// </summary> /// <param name="callback"></param> public void GetTicket(GetTicketHandler callback) { GCHandle wrapped = GCHandle.Alloc(callback); Methods.GetTicket(methodsPtr, GCHandle.ToIntPtr(wrapped), GetTicketCallbackImpl); }