question

michaelbb avatar image
michaelbb asked

C#/UWP: Use of Shared Group Data

Hi there,

I try to implement shared Group data into my UWP Windows10 Project but I am a bit lost:

When trying to create a Group I don't even get an error message, it just does not work.

I have just the following but don't know what's not working.

I was also Looking for an example/sample but just could find a cloudscript one.

Any help would be appreciated.

Many thanks,

Michael

 public async static void CreateSharedData()
        {
            var dc = new Dictionary<string, string>()
            {
                { "test", "sssde" }
            };
            
            var shared = await PlayFabClientAPI.CreateSharedGroupAsync(new CreateSharedGroupRequest()
            {
                SharedGroupId = dc.ToString()
                
            });
            if (shared.Result != null)
            {
                
            }
Shared Group Datawindows
10 |1200

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

jital avatar image
jital answered

Hello,

CreateSharedGroup creates a group data object with the ID of SharedGroupId.

In your code what is happening is you are creating this shared group data object with the id of "System.Collections.Generic.Dictionary`2[System.String,System.String]"

If you go into the GameManager->Players->Shared Group Data and search the string exactly you will be able to see if this group data object was created.

I have included a screenshot of what this looks like in the Game Manager sharegroupdata.png

If you are trying to save your Dictionary entry into the group data object you need call UpdateSharedgroupData.

Below is a code sample:

Dictionary<string, string> dc = new Dictionary<string, string>()
{
	{"test","lwlwlw" }
};


CreateSharedGroupRequest createSharedGroupRequest = new CreateSharedGroupRequest
{
	SharedGroupId = dc.ToString()
};


var createTask = PlayFabClientAPI.CreateSharedGroupAsync(createSharedGroupRequest);
createTask.Wait();


if(createTask.Result != null)
{
	Console.WriteLine(createTask.Result);
	UpdateSharedGroupDataRequest updateSharedGroupDataRequest = new UpdateSharedGroupDataRequest
        {
        	Data = dc,
                SharedGroupId = dc.ToString()
        };


	var updateTask = PlayFabClientAPI.UpdateSharedGroupDataAsync(updateSharedGroupDataRequest);

	updateTask.Wait();


   	if(updateTask.Result != null)
        {
        	Console.WriteLine("Successful update");
        }


}

And here is the same image in the Game Manager After the UpdateSharedgroupData call updategroupdata.png


sharegroupdata.png (30.4 KiB)
updategroupdata.png (29.4 KiB)
10 |1200

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

michaelbb avatar image
michaelbb answered

Hi @jital,

I fear I've a further question regarding the issue above.

Is that normal that I am not able to see shared data ?

When clicking on that tab "shared data" for a players that shares data with another one, I cannot see anything. I have to fill in SharedGroupId to get back results.

Many thanks and best wishes,

Michael

1 comment
10 |1200

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

jital avatar image jital ♦ commented ·

Greetings,

Yes that is how the Shared Group Data works. It requires you to enter the exact ShardGroupId in order to view any information.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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