Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MrLucid72 · Mar 06, 2017 at 04:58 AM · steamcallback

How to wait for a CallResult from Steamworks.NET? I can't just =>

For example, to get an AuthTicket, I have these

 private CallResult<NumberOfCurrentPlayers_t> m_NumberOfCurrentPlayers;
 private Callback<GetAuthSessionTicketResponse_t> m_GetAuthSessionTicketResponse;

then OnEnable():

 m_NumberOfCurrentPlayers = CallResult<NumberOfCurrentPlayers_t>.Create(OnNumberOfCurrentPlayers);
 m_GetAuthSessionTicketResponse = Callback<GetAuthSessionTicketResponse_t>.Create(OnGetAuthSessionTicketResponse);

So when I finally make the call:

 public string GetAuthSessionTicket()
 {
     // ...
     hTicket = SteamUser.GetAuthSessionTicket(ticketBlob, ticketBlob.Length, out ticketSize); // Triggers OnGetAuthSessionTicketResponse to be called shortly
 
     return "NotReadyYet" // I have to wait for callback! How do I do this? Normally I can just (result) => but I can't for this situation (that I know of).
 }
 
 private void OnGetAuthSessionTicketResponse(GetAuthSessionTicketResponse_t callback)
 {
     Debug.Log("ticket == " + callback.hTicket + " / " + callback.eResult );
     // NOW I have the real value ... but how do I possibly return?
 }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Mar 06, 2017 at 12:30 PM

Well, if the request is asynchronous you can't just make is synchronous without blocking the main thread. If the callback is synchronous (if it's called from within the "GetAuthSessionTicket" method) you could use a lambda expression which you assign to the callback just before you call "GetAuthSessionTicket".

However even i never worked with the Steamworks API, it looks like the callback doesn't provide any "new" information. The callback just has the ticket handle which is already returned by "GetAuthSessionTicket". If you look at this example i've found you actually don't care much about the ticket handle, but about your "ticketBlob" and "ticketSize" which are filled / set immediately by the "GetAuthSessionTicket" method.

I'm not sure why you want to return a string. The ticket seems to be a binary blob. Of course you could encode the first "ticketSize" bytes from the ticketBlob as hex or base64 string, but whenever you need to use the ticket you have to convert it back. So it would make more sense to just keep the ticketBlob / ticketSize as it is. If you don't want to "waste" memory you could "shorten" the array to the length of ticketSize. This could be done with Array.Resize(ref ticketBlob, ticketSize); or by creating a new array with the length of ticketSize and copy over the data. Having the ticketBlob size adjusted would mean you don't need to store the ticketSize seperately.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MrLucid72 · Mar 06, 2017 at 12:51 PM 0
Share

Thank you so much ;D yea it seems I don't need to wait for the callback. I turned it into a hex string for use with 3rd party authentication (PlayFab).

Excellent examples!

avatar image pjbaron · May 08, 2018 at 03:37 AM 0
Share

Just a quick note: it is essential to wait for the callback because the player may not own the game. If the callback returns a fail code then we should abort immediately.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

65 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Steamworks SetLobbyMemberData not triggering LobbyDataUpdate_t 0 Answers

Steam Leaderboard delays 1 Answer

Apply Local Rotations to VR Camera 0 Answers

Interaction with UI using SteamVR 0 Answers

How to add Steam Vr Script "Interactable" during runtime without crashing on interact 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges