question

appgame avatar image
appgame asked

Transferring Live Match from Device-A to Device-B with same PlayfabID Login

Hello,

When Transferring Live Match from Xbox/Playstation or Phone/Tablet?

Best guess...

server.LoginWith (???)



handlers.SetDeviceAfterLogin = (args, context) => {

	var Data = server.GetUserData({ PlayFabId: args.PlayFabId }).Data;

	if( Data.Devices == undefined ){
		Data['Devices'] = [];
	}


	Data.Devices.push( { "PlayFabId": args.PlayFabId, "SessionTicket": args.SessionTicket, "EntityToken": args.EntityToken , "MatchId
" : args.MatchId
});


	server.UpdateUserData({
		"PlayFabId": args.PlayFabId,
		"Data": Data,
		"Permission": "Public"
	});


	id( args.Return == true ){
        	return {
            		LinkedDevices : Data.Devices
        	};
	}
}





handlers.GetLinkedDevices = (args, context) => {

	var Data = server.GetUserData({ PlayFabId: args.PlayFabId }).Data;

        return {
            LinkedDevices : Data.Devices
        };

}





handlers.DeleteLinkedDevice = (args, context) => {

	var Data = server.GetUserData({ PlayFabId: args.PlayFabId }).Data;


	var index = Data.Devices.map(function(d) { return d['PlayFabId']; }).indexOf( args.PlayFabId );
	Data.Devices.array.splice(index, 1);


	server.UpdateUserData({
		"PlayFabId": args.PlayFabId,
		"Data": Data,
		"Permission": "Public"
	});


	id( args.Return == true ){
        	return {
            		LinkedDevices : Data.Devices
        	};
	}

}

Device-A to Device-B

  1. Match Progress Data
  2. MatchId: "4e0c5fd7-..."
  3. SessionTicket: "403B086D...."
  4. EntityToken: "Mnx7ImkiOi..."
  5. Device-B Retrieves GetMatch() info
  6. Load Game on new Device
6 comments
10 |1200

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

Citrus Yan avatar image Citrus Yan commented ·

I don't follow, could you please elaborate on what feature are you trying to implement?

0 Likes 0 ·
appgame avatar image appgame Citrus Yan commented ·

Hello

  1. multiplayer.GetMatch not server.GetMatch
0 Likes 0 ·
appgame avatar image appgame Citrus Yan commented ·

Hello,

Fixed multiplayer.GetMatch()

  1. server.UpdateUserData() Wont the Update UserData.
handlers.CustomGetMatch = (args, context) => {
    try {
        
        var Match = multiplayer.GetMatch({
            MatchId: args.MatchId,
            QueueName: args.QueueName,
            EscapeObject: true,
            ReturnMemberAttributes: true
        });


        var F = server.GetUserData({ PlayFabId: args.PlayFabId });
        F.Data["LiveMatch"] = Match;
        GameData = F;
	
	var Update = server.UpdateUserData({
            "PlayFabId": args.PlayFabId,
            "Data": GameData,
            "Permission": "Public"
	});


	if( args.Return == "true" ){ 
           var F = server.GetUserData({ PlayFabId: args.PlayFabId });
           return {
             data: Match, "GetUserData": F, "GameData": GameData
           };
	 }else{
           return {
             data: Match
           };
	 }
    
    } catch (ex) {
        let error = ex.apiErrorInfo.apiError.error;
        let errorCode = ex.apiErrorInfo.apiError.errorCode;
    };


}

0 Likes 0 ·
appgame avatar image appgame commented ·

Delete Comment

0 Likes 0 ·
appgame avatar image appgame commented ·
Delete Comment
0 Likes 0 ·
appgame avatar image appgame commented ·
  1. The number of player data key/value pairs which may be updated in a single request is limited to 10
0 Likes 0 ·

1 Answer

·
appgame avatar image
appgame answered
var Update = server.UpdateUserData({
	"PlayFabId": args.PlayFabId,
            /** "Data": GameData, ** Was Missing .Data  **/
	"Data": GameData.Data,
	"Permission": "Public"
});
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.