question

shashchamp avatar image
shashchamp asked

How to implement WhispersyncEventListener in Unity

Is there any docs for unity? Can someone please tell how to implement WhispersyncEventListener for Unity. Thanks
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
using (AGSGameDataMap dataMap = AGSWhispersyncClient.GetGameData()) { using (AGSSyncableNumber myHighNumber = dataMap.GetHighestNumber("myHighNumber")) { myHighNumber.Set (1000); } } reference: https://developer.amazon.com/sdk/gamecircle/documentation/unity-gamecircle-features.html
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shashchamp avatar image
shashchamp answered
static public void UpdateCloudData(){ Debug.Log("Dcube : In UpdateCloudData");
using(AGSGameDataMap dataMap = AGSWhispersyncClient.GetGameData()){
using(AGSSyncableNumber myHighNumber = dataMap.GetHighestNumber("myHighNumber")){
myHighNumber.Set(9999);
dataMap.GetLatestString("gameData").Set("Save Me to Cloud");
Debug.Log("Dcube : UpdateCloudData"+myHighNumber.ToString());
}
}
Debug.Log("Dcube : end UpdateCloudData");
UpdateLocalData();
}
static public void UpdateLocalData(){
Debug.Log("Dcube : UpdateLocalData start");
using(AGSGameDataMap dataMap = AGSWhispersyncClient.GetGameData()){
using(AGSSyncableNumber myHighNumber = dataMap.GetHighestNumber("myHighNumber")){
Debug.Log("Dcube : UpdateLocalData "+ myHighNumber.ToString());
AGSSyncableString savedfile = dataMap.GetLatestString("gameData");
Debug.Log("Dcube : UpdateLocalData "+ savedfile.ToString());
}
}

}


Output
09-11 17:03:13.611: I/Unity(3021): Dcube : In UpdateCloudData
09-11 17:03:13.619: I/Unity(3021): Dcube : UpdateCloudData AGSSyncableNumber
09-11 17:03:13.619: I/Unity(3021): Dcube : end UpdateCloudData
09-11 17:03:13.619: I/Unity(3021): Dcube : UpdateLocalData start
09-11 17:03:13.619: I/Unity(3021): Dcube : UpdateLocalData AGSSyncableNumber
09-11 17:03:13.619: I/Unity(3021): Dcube : UpdateLocalData AGSSyncableString
09-11 17:09:44.111: I/Unity(3021): Dcube : Client GameCircle - IsService is ready

While retrieving the data I am getting AGSSyncableNumber AGSSyncableString instead of 9999 and the string value

I am able to see data being synced under GC_Whispersync tag
09-11 17:03:14.236: V/GC_Whispersync(3021): Adding JSON element [{"state":"SYNCED","ts":1378896071,"value":9999}]
Can someone tell me whats going wrong here?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shashchamp avatar image
shashchamp answered
I even tried using using(AGSGameDataMap dataMap = AGSWhispersyncClient.GetGameData()){ AGSSyncableString savedfile = dataMap.GetLatestString("gameData"); Debug.Log("Dcube : UpdateLocalData"+dataMap.GetLatestString("gameData").ToString()); Debug.Log("Dcube : UpdateLocalData"+dataMap.GetHighestNumber("myHighNumber").ToString()); But still the same output. Message was edited by: shashchamp
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Shashchamp, Thank you for writing to us. I can see from above code that you are setting the highest number as integer. myHighNumber.Set(9999); And in json it's reflecting as integer [{"state":"SYNCED","ts":1378896071,[b]"value":9999[/b]}] Which is correct. Now get the integer value out of AGSSyncableNumber instance, you should this, myHighNumber.AsInt();
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.