How do I desiralize the webhooks binary text?

bang10
bang10
edited January 2023 in Photon Server

I am using photon-webhook v1.2 with Azure.

As shown in the following example,

I'm trying to decode base64, but I'm asking because it didn't go well.

====================================================

Azure function app


[ input ]

------------------------------------------------------------------------------------------------

"Binary":{"18":"RAAAAAVzAAhHYW1lRmxvd2kAAAABcwADcmR2aR7qYwti+nkAAnMAAkMwAAJDMXMAAkMwaQAAAZBzAAJDMXMABE1hcDM="}


------------------------------------------------------------------------------------------------

[ example code ]

    public class MyClass

    {

      public int GameFlow;

      public long rdv;

     }


    public static T FromBase64<T>(string data)

    {

      var base64EncodedBytes = Convert.FromBase64String(data);

      string parsedString = Encoding.UTF8.GetString(base64EncodedBytes);

   

      return JsonConvert.DeserializeObject<T>(parsedString); // what should I do ?

    }


    string byText = gdRequest.State.Binary["18"];

    MyClass myClass = FromBase64<MyClass>(byText);


Thank you in advance.

Answers

  • hi, @bang10

    this part that you try to deserialize is internal part. Not sure why you are trying to deserialize it this way

    in any case you can decompile and check what we do. However what you are doing looks correct to me


    best,

    ilya