Skip to content

Commit 0646843

Browse files
committed
Updated log and docs
1 parent 61c3157 commit 0646843

2 files changed

Lines changed: 169 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Doing this gives you the ability to modify the texture before this happens, allo
115115

116116
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
117117

118-
@johanlindfors @Arthur3DLHC
118+
@johanlindfors @Arthur3DLHC @JamesSkemp
119119

120120
## Version 3.12.0 - Silica - 4th September 2018
121121

plugins/fbinstant/src/FacebookInstantGamesPlugin.js

Lines changed: 168 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ var FacebookInstantGamesPlugin = new Class({
931931
* @method Phaser.Boot.FacebookInstantGamesPlugin#saveStats
932932
* @since 3.13.0
933933
*
934-
* @param {any} data - An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored.
934+
* @param {object} data - An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored.
935935
*
936936
* @return {this} This Facebook Instant Games Plugin instance.
937937
*/
@@ -992,7 +992,7 @@ var FacebookInstantGamesPlugin = new Class({
992992
* @method Phaser.Boot.FacebookInstantGamesPlugin#incStats
993993
* @since 3.13.0
994994
*
995-
* @param {any} data - An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed.
995+
* @param {object} data - An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed.
996996
*
997997
* @return {this} This Facebook Instant Games Plugin instance.
998998
*/
@@ -1027,6 +1027,20 @@ var FacebookInstantGamesPlugin = new Class({
10271027
return this;
10281028
},
10291029

1030+
/**
1031+
* Sets the data associated with the individual gameplay session for the current context.
1032+
*
1033+
* This function should be called whenever the game would like to update the current session data.
1034+
*
1035+
* This session data may be used to populate a variety of payloads, such as game play webhooks.
1036+
*
1037+
* @method Phaser.Boot.FacebookInstantGamesPlugin#saveSession
1038+
* @since 3.13.0
1039+
*
1040+
* @param {object} data - An arbitrary data object, which must be less than or equal to 1000 characters when stringified.
1041+
*
1042+
* @return {this} This Facebook Instant Games Plugin instance.
1043+
*/
10301044
saveSession: function (data)
10311045
{
10321046
if (!this.checkAPI('setSessionData'))
@@ -1048,26 +1062,125 @@ var FacebookInstantGamesPlugin = new Class({
10481062
return this;
10491063
},
10501064

1065+
/**
1066+
* This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline.
1067+
*
1068+
* A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property.
1069+
*
1070+
* This data must be less than or equal to 1000 characters when stringified.
1071+
*
1072+
* When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed.
1073+
*
1074+
* The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not.
1075+
*
1076+
* @method Phaser.Boot.FacebookInstantGamesPlugin#openShare
1077+
* @since 3.13.0
1078+
*
1079+
* @param {string} text - A text message to be shared.
1080+
* @param {string} key - The key of the texture to use as the share image.
1081+
* @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data.
1082+
* @param {object} [sessionData] - A blob of data to attach to the share.
1083+
*
1084+
* @return {this} This Facebook Instant Games Plugin instance.
1085+
*/
10511086
openShare: function (text, key, frame, sessionData)
10521087
{
10531088
return this._share('SHARE', text, key, frame, sessionData);
10541089
},
10551090

1091+
/**
1092+
* This invokes a dialog to let the user invite a friend to play this game, either as a message in Messenger or as a post on the user's timeline.
1093+
*
1094+
* A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property.
1095+
*
1096+
* This data must be less than or equal to 1000 characters when stringified.
1097+
*
1098+
* When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed.
1099+
*
1100+
* The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not.
1101+
*
1102+
* @method Phaser.Boot.FacebookInstantGamesPlugin#openInvite
1103+
* @since 3.13.0
1104+
*
1105+
* @param {string} text - A text message to be shared.
1106+
* @param {string} key - The key of the texture to use as the share image.
1107+
* @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data.
1108+
* @param {object} [sessionData] - A blob of data to attach to the share.
1109+
*
1110+
* @return {this} This Facebook Instant Games Plugin instance.
1111+
*/
10561112
openInvite: function (text, key, frame, sessionData)
10571113
{
10581114
return this._share('INVITE', text, key, frame, sessionData);
10591115
},
10601116

1117+
/**
1118+
* This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline.
1119+
*
1120+
* A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property.
1121+
*
1122+
* This data must be less than or equal to 1000 characters when stringified.
1123+
*
1124+
* When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed.
1125+
*
1126+
* The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not.
1127+
*
1128+
* @method Phaser.Boot.FacebookInstantGamesPlugin#openRequest
1129+
* @since 3.13.0
1130+
*
1131+
* @param {string} text - A text message to be shared.
1132+
* @param {string} key - The key of the texture to use as the share image.
1133+
* @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data.
1134+
* @param {object} [sessionData] - A blob of data to attach to the share.
1135+
*
1136+
* @return {this} This Facebook Instant Games Plugin instance.
1137+
*/
10611138
openRequest: function (text, key, frame, sessionData)
10621139
{
10631140
return this._share('REQUEST', text, key, frame, sessionData);
10641141
},
10651142

1143+
/**
1144+
* This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline.
1145+
*
1146+
* A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property.
1147+
*
1148+
* This data must be less than or equal to 1000 characters when stringified.
1149+
*
1150+
* When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed.
1151+
*
1152+
* The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not.
1153+
*
1154+
* @method Phaser.Boot.FacebookInstantGamesPlugin#openChallenge
1155+
* @since 3.13.0
1156+
*
1157+
* @param {string} text - A text message to be shared.
1158+
* @param {string} key - The key of the texture to use as the share image.
1159+
* @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data.
1160+
* @param {object} [sessionData] - A blob of data to attach to the share.
1161+
*
1162+
* @return {this} This Facebook Instant Games Plugin instance.
1163+
*/
10661164
openChallenge: function (text, key, frame, sessionData)
10671165
{
10681166
return this._share('CHALLENGE', text, key, frame, sessionData);
10691167
},
10701168

1169+
/**
1170+
* Internal share handler.
1171+
*
1172+
* @method Phaser.Boot.FacebookInstantGamesPlugin#_share
1173+
* @private
1174+
* @since 3.13.0
1175+
*
1176+
* @param {string} intent - ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share.
1177+
* @param {string} text - A text message to be shared.
1178+
* @param {string} key - The key of the texture to use as the share image.
1179+
* @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data.
1180+
* @param {object} [sessionData] - A blob of data to attach to the share.
1181+
*
1182+
* @return {this} This Facebook Instant Games Plugin instance.
1183+
*/
10711184
_share: function (intent, text, key, frame, sessionData)
10721185
{
10731186
if (!this.checkAPI('shareAsync'))
@@ -1082,20 +1195,18 @@ var FacebookInstantGamesPlugin = new Class({
10821195
var imageData = this.game.textures.getBase64(key, frame);
10831196
}
10841197

1198+
// intent ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share.
1199+
// image string A base64 encoded image to be shared.
1200+
// text string A text message to be shared.
1201+
// data Object? A blob of data to attach to the share. All game sessions launched from the share will be able to access this blob through FBInstant.getEntryPointData().
1202+
10851203
var payload = {
10861204
intent: intent,
10871205
image: imageData,
10881206
text: text,
10891207
data: sessionData
10901208
};
10911209

1092-
// console.log(payload);
1093-
1094-
// intent ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share.
1095-
// image string A base64 encoded image to be shared.
1096-
// text string A text message to be shared.
1097-
// data Object? A blob of data to attach to the share. All game sessions launched from the share will be able to access this blob through FBInstant.getEntryPointData().
1098-
10991210
var _this = this;
11001211

11011212
FBInstant.shareAsync(payload).then(function ()
@@ -1106,6 +1217,20 @@ var FacebookInstantGamesPlugin = new Class({
11061217
return this;
11071218
},
11081219

1220+
/**
1221+
* This function determines whether the number of participants in the current game context is between a given minimum and maximum, inclusive.
1222+
* If one of the bounds is null only the other bound will be checked against.
1223+
* It will always return the original result for the first call made in a context in a given game play session.
1224+
* Subsequent calls, regardless of arguments, will return the answer to the original query until a context change occurs and the query result is reset.
1225+
*
1226+
* @method Phaser.Boot.FacebookInstantGamesPlugin#isSizeBetween
1227+
* @since 3.13.0
1228+
*
1229+
* @param {integer} [min] - The minimum bound of the context size query.
1230+
* @param {integer} [max] - The maximum bound of the context size query.
1231+
*
1232+
* @return {object} The Context Size Response object in the format: `{answer: boolean, minSize: number?, maxSize: number?}`.
1233+
*/
11091234
isSizeBetween: function (min, max)
11101235
{
11111236
if (!this.checkAPI('contextIsSizeBetween'))
@@ -1116,6 +1241,19 @@ var FacebookInstantGamesPlugin = new Class({
11161241
return FBInstant.context.isSizeBetween(min, max);
11171242
},
11181243

1244+
/**
1245+
* Request a switch into a specific context. If the player does not have permission to enter that context,
1246+
* or if the player does not provide permission for the game to enter that context, this will emit a `switchfail` event.
1247+
*
1248+
* Otherwise, the plugin will emit the `switch` event when the game has switched into the specified context.
1249+
*
1250+
* @method Phaser.Boot.FacebookInstantGamesPlugin#switchContext
1251+
* @since 3.13.0
1252+
*
1253+
* @param {string} contextID - The ID of the desired context.
1254+
*
1255+
* @return {this} This Facebook Instant Games Plugin instance.
1256+
*/
11191257
switchContext: function (contextID)
11201258
{
11211259
if (!this.checkAPI('contextSwitchAsync'))
@@ -1130,13 +1268,30 @@ var FacebookInstantGamesPlugin = new Class({
11301268
FBInstant.context.switchAsync(contextID).then(function ()
11311269
{
11321270
_this.contextID = FBInstant.context.getID();
1271+
11331272
_this.emit('switch', _this.contextID);
1273+
1274+
}).catch(function (e)
1275+
{
1276+
_this.emit('switchfail', e);
11341277
});
11351278
}
11361279

11371280
return this;
11381281
},
11391282

1283+
/**
1284+
* Opens a context selection dialog for the player. If the player selects an available context,
1285+
* the client will attempt to switch into that context, and emit th `choose` event if successful.
1286+
* Otherwise, if the player exits the menu or the client fails to switch into the new context, the `choosefail` event will be emitted.
1287+
*
1288+
* @method Phaser.Boot.FacebookInstantGamesPlugin#chooseContext
1289+
* @since 3.13.0
1290+
*
1291+
* @param {string} contextID - The ID of the desired context.
1292+
*
1293+
* @return {this} This Facebook Instant Games Plugin instance.
1294+
*/
11401295
chooseContext: function (options)
11411296
{
11421297
if (!this.checkAPI('contextChoseAsync'))
@@ -1150,6 +1305,10 @@ var FacebookInstantGamesPlugin = new Class({
11501305
{
11511306
_this.contextID = FBInstant.context.getID();
11521307
_this.emit('choose', _this.contextID);
1308+
1309+
}).catch(function (e)
1310+
{
1311+
_this.emit('choosefail', e);
11531312
});
11541313

11551314
return this;

0 commit comments

Comments
 (0)