@@ -8,6 +8,7 @@ if(!PlayFab.settings) {
88 developerSecretKey : null , // For security reasons you must never expose this value to the client or players - You must set this value for Server-APIs to work properly (Found in the Game Manager for your title, at the PlayFab Website)
99 advertisingIdType : null ,
1010 advertisingIdValue : null ,
11+ GlobalHeaderInjection : null ,
1112
1213 // disableAdvertising is provided for completeness, but changing it is not suggested
1314 // Disabling this may prevent your advertising-related PlayFab marketplace partners from working correctly
@@ -29,26 +30,40 @@ if(!PlayFab._internalSettings) {
2930 return "https://" + PlayFab . settings . titleId + PlayFab . _internalSettings . productionServerUrl ;
3031 } ,
3132
32- ExecuteRequest : function ( completeUrl , data , authkey , authValue , callback ) {
33+ InjectHeaders : function ( xhr , headersObj ) {
34+ if ( ! headersObj )
35+ return ;
36+
37+ for ( var headerKey in headersObj )
38+ {
39+ try {
40+ xhr . setRequestHeader ( gHeaderKey , headersObj [ headerKey ] ) ;
41+ } catch ( e ) {
42+ console . log ( "Failed to append header: " + headerKey + " = " + headersObj [ headerKey ] ) ;
43+ }
44+ }
45+ } ,
46+
47+ ExecuteRequest : function ( completeUrl , request , authkey , authValue , callback , customData , extraHeaders ) {
3348 if ( callback != null && typeof ( callback ) != "function" )
3449 throw "Callback must be null of a function" ;
3550
36- if ( data == null )
37- data = { } ;
51+ if ( request == null )
52+ request = { } ;
3853
3954 var startTime = new Date ( ) ;
40- var requestBody = JSON . stringify ( data ) ;
55+ var requestBody = JSON . stringify ( request ) ;
4156
4257 var xhr = new XMLHttpRequest ( ) ;
4358 // window.console.log("URL: " + completeUrl);
4459 xhr . open ( "POST" , completeUrl , true ) ;
4560
4661 xhr . setRequestHeader ( 'Content-Type' , 'application/json' ) ;
47-
62+ xhr . setRequestHeader ( 'X-PlayFabSDK' , "JavaScriptSDK-" + PlayFab . _internalSettings . sdkVersion ) ;
4863 if ( authkey != null )
4964 xhr . setRequestHeader ( authkey , authValue ) ;
50-
51- xhr . setRequestHeader ( 'X-PlayFabSDK' , "JavaScriptSDK-" + PlayFab . _internalSettings . sdkVersion ) ;
65+ PlayFab . _internalSettings . InjectHeaders ( xhr , PlayFab . settings . GlobalHeaderInjection ) ;
66+ PlayFab . _internalSettings . InjectHeaders ( xhr , extraHeaders ) ;
5267
5368 xhr . onloadend = function ( ) {
5469 if ( callback == null )
@@ -69,6 +84,8 @@ if(!PlayFab._internalSettings) {
6984 }
7085
7186 result . CallBackTimeMS = new Date ( ) - startTime ;
87+ result . Request = request ;
88+ result . CustomData = customData ;
7289
7390 if ( result . code === 200 )
7491 callback ( result , null ) ;
@@ -94,6 +111,9 @@ if(!PlayFab._internalSettings) {
94111 }
95112
96113 result . CallBackTimeMS = new Date ( ) - startTime ;
114+ result . Request = request ;
115+ result . CustomData = customData ;
116+
97117 callback ( null , result ) ;
98118 }
99119
@@ -102,39 +122,48 @@ if(!PlayFab._internalSettings) {
102122 }
103123}
104124
105- PlayFab . buildIdentifier = "jbuild_javascriptsdk_1" ;
106- PlayFab . sdkVersion = "1.11.170828" ;
125+ PlayFab . buildIdentifier = "jbuild_javascriptsdk_0" ;
126+ PlayFab . sdkVersion = "1.12.170925" ;
127+ PlayFab . GenerateErrorReport = function ( error ) {
128+ if ( error == null )
129+ return "" ;
130+ var fullErrors = error . errorMessage ;
131+ for ( var paramName in error . errorDetails )
132+ for ( var msgIdx in error . errorDetails [ paramName ] )
133+ fullErrors += "\n" + paramName + ": " + error . errorDetails [ paramName ] [ msgIdx ] ;
134+ return fullErrors ;
135+ } ;
107136
108137PlayFab . MatchmakerApi = {
109138
110- AuthUser : function ( request , callback ) {
139+ AuthUser : function ( request , callback , customData , extraHeaders ) {
111140 if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
112141
113- PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/AuthUser" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback ) ;
142+ PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/AuthUser" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback , customData , extraHeaders ) ;
114143 } ,
115144
116- PlayerJoined : function ( request , callback ) {
145+ PlayerJoined : function ( request , callback , customData , extraHeaders ) {
117146 if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
118147
119- PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/PlayerJoined" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback ) ;
148+ PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/PlayerJoined" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback , customData , extraHeaders ) ;
120149 } ,
121150
122- PlayerLeft : function ( request , callback ) {
151+ PlayerLeft : function ( request , callback , customData , extraHeaders ) {
123152 if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
124153
125- PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/PlayerLeft" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback ) ;
154+ PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/PlayerLeft" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback , customData , extraHeaders ) ;
126155 } ,
127156
128- StartGame : function ( request , callback ) {
157+ StartGame : function ( request , callback , customData , extraHeaders ) {
129158 if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
130159
131- PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/StartGame" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback ) ;
160+ PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/StartGame" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback , customData , extraHeaders ) ;
132161 } ,
133162
134- UserInfo : function ( request , callback ) {
163+ UserInfo : function ( request , callback , customData , extraHeaders ) {
135164 if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
136165
137- PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/UserInfo" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback ) ;
166+ PlayFab . _internalSettings . ExecuteRequest ( PlayFab . _internalSettings . GetServerUrl ( ) + "/Matchmaker/UserInfo" , request , "X-SecretKey" , PlayFab . settings . developerSecretKey , callback , customData , extraHeaders ) ;
138167 } ,
139168} ;
140169
0 commit comments