@@ -8,6 +8,7 @@ if(!PlayFab.settings) {
8
8
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)
9
9
advertisingIdType : null ,
10
10
advertisingIdValue : null ,
11
+ GlobalHeaderInjection : null ,
11
12
12
13
// disableAdvertising is provided for completeness, but changing it is not suggested
13
14
// Disabling this may prevent your advertising-related PlayFab marketplace partners from working correctly
@@ -29,26 +30,40 @@ if(!PlayFab._internalSettings) {
29
30
return "https://" + PlayFab . settings . titleId + PlayFab . _internalSettings . productionServerUrl ;
30
31
} ,
31
32
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 ) {
33
48
if ( callback != null && typeof ( callback ) != "function" )
34
49
throw "Callback must be null of a function" ;
35
50
36
- if ( data == null )
37
- data = { } ;
51
+ if ( request == null )
52
+ request = { } ;
38
53
39
54
var startTime = new Date ( ) ;
40
- var requestBody = JSON . stringify ( data ) ;
55
+ var requestBody = JSON . stringify ( request ) ;
41
56
42
57
var xhr = new XMLHttpRequest ( ) ;
43
58
// window.console.log("URL: " + completeUrl);
44
59
xhr . open ( "POST" , completeUrl , true ) ;
45
60
46
61
xhr . setRequestHeader ( 'Content-Type' , 'application/json' ) ;
47
-
62
+ xhr . setRequestHeader ( 'X-PlayFabSDK' , "JavaScriptSDK-" + PlayFab . _internalSettings . sdkVersion ) ;
48
63
if ( authkey != null )
49
64
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 ) ;
52
67
53
68
xhr . onloadend = function ( ) {
54
69
if ( callback == null )
@@ -69,6 +84,8 @@ if(!PlayFab._internalSettings) {
69
84
}
70
85
71
86
result . CallBackTimeMS = new Date ( ) - startTime ;
87
+ result . Request = request ;
88
+ result . CustomData = customData ;
72
89
73
90
if ( result . code === 200 )
74
91
callback ( result , null ) ;
@@ -94,6 +111,9 @@ if(!PlayFab._internalSettings) {
94
111
}
95
112
96
113
result . CallBackTimeMS = new Date ( ) - startTime ;
114
+ result . Request = request ;
115
+ result . CustomData = customData ;
116
+
97
117
callback ( null , result ) ;
98
118
}
99
119
@@ -102,39 +122,48 @@ if(!PlayFab._internalSettings) {
102
122
}
103
123
}
104
124
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
+ } ;
107
136
108
137
PlayFab . MatchmakerApi = {
109
138
110
- AuthUser : function ( request , callback ) {
139
+ AuthUser : function ( request , callback , customData , extraHeaders ) {
111
140
if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
112
141
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 ) ;
114
143
} ,
115
144
116
- PlayerJoined : function ( request , callback ) {
145
+ PlayerJoined : function ( request , callback , customData , extraHeaders ) {
117
146
if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
118
147
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 ) ;
120
149
} ,
121
150
122
- PlayerLeft : function ( request , callback ) {
151
+ PlayerLeft : function ( request , callback , customData , extraHeaders ) {
123
152
if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
124
153
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 ) ;
126
155
} ,
127
156
128
- StartGame : function ( request , callback ) {
157
+ StartGame : function ( request , callback , customData , extraHeaders ) {
129
158
if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
130
159
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 ) ;
132
161
} ,
133
162
134
- UserInfo : function ( request , callback ) {
163
+ UserInfo : function ( request , callback , customData , extraHeaders ) {
135
164
if ( ! PlayFab . settings . developerSecretKey ) throw PlayFab . _internalSettings . errorSecretKey ;
136
165
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 ) ;
138
167
} ,
139
168
} ;
140
169
0 commit comments