question

vl.fedin@gmail.com avatar image
vl.fedin@gmail.com asked

Why second call to server.SetPublisherData won't affect data?


function GetClanListHead()
{
var result = server.GetPublisherData
({
"Keys": [ "clanListHead" ]
});

if( 'clanListHead' in result.Data )
{
return result.Data.clanListHead;
}
else
{
return "";
}
}

function SetClanListHead(groupName)
{
var result = server.SetPublisherData
({
"Key" : "clanListHead",
"Value" : groupName
});
return result;
}

handlers.CreateClan = function( args )
{

// clanListHead is equal to "CLAN_03" now
SetClanListHead( "CLAN_03" );
var v1 = "first: " + GetClanListHead();

// clanListHead is still equal to "CLAN_03"
SetClanListHead( "CLAN_04" );
var v2 = "second: " + GetClanListHead();
//return v1 + ", " + v2;
var result = server.GetPublisherData
({
"Keys": [ "clanListHead" ]
});
return result;


// return { messageValue: ( args.playFabId + "_" + args.clanName + "_" + args.leaderName ) };
}

10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

Attempting to update the same Key to two different Values within a few milliseconds like this isn't really viable. With large-scale backend systems, the data is stored across multiple servers, which require synchronization. So two calls to write to the same Key within a few milliseconds (as in this case) isn't going to work the way it would on a single PC, where all the data is stored in a single database.

10 |1200

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

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.