Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Receive a callback to client from Cloud Code when a C# module is invoked via a trigger.

Discussion in 'Cloud Code' started by ByteflowX, Apr 2, 2024.

  1. ByteflowX

    ByteflowX

    Joined:
    Mar 20, 2024
    Posts:
    6
    I am following the example in the guide and I have a question. How can I receive a callback from a C# module in Cloud Code when default configuration values have been set?

    Here's what I mean:

    1. A trigger calls Cloud Code (a C# module).
    2. In Cloud Code, the method InitializeNewPlayer is called:

      Code (CSharp):
      1. await gameApiClient.CloudSaveData.SetItemBatchAsync(ctx, ctx.ServiceToken, ctx.ProjectId, playerId,
      2.                     new SetItemBatchBody(new List<SetItemBody>{new (HealthKey, DefaultValue), new (StaminaKey, DefaultValue)}));
    3. Upon completion of the method in Cloud Code, I want to update the player's data in Unity by calling

      Code (CSharp):
      1. var playerData = await CloudSaveService.Instance.Data.Player.LoadAsync
    4. This is to ensure that the player sees updated data in the game. Is there any callback mechanism available from the Cloud Code module other than sending a push message with await pushClient.SendPlayerMessageAsync? Are there any other options available?
     
  2. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    241
    ByteflowX likes this.
  3. samg-unity

    samg-unity

    Unity Technologies

    Joined:
    Mar 23, 2021
    Posts:
    47
    Hi @ByteflowX

    Edit - provided an answer, but then I saw you'd already mentioned it in your point 4. Using the push client is the only mechanism we currently provide as part of Cloud Code - what other options/ features were you hoping to use that the push client doesn't provide?
     
  4. ByteflowX

    ByteflowX

    Joined:
    Mar 20, 2024
    Posts:
    6
    Push notifications suit me well, thank you!