-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcocoon_multiplayer_googleplaygames.js
More file actions
77 lines (70 loc) · 2.69 KB
/
cocoon_multiplayer_googleplaygames.js
File metadata and controls
77 lines (70 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
(function() {
if (window.cordova && typeof require !== 'undefined') {
require('cocoon-plugin-multiplayer-common.Multiplayer'); //force dependency load
}
var Cocoon = window.Cocoon;
/**
* This namespace provides an abstraction API for the Google Play Games Multiplayer Service.
* @namespace Cocoon.Multiplayer.GooglePlayGames
* @example
* var GooglePlayGames = Cocoon.Social.GooglePlayGames;
* GooglePlayGames.init({
* defaultLeaderboard: "xxxxx"
* });
* var SocialGooglePlayGames = gpg.getSocialInterface();
* var MultiplayerGooglePlayGames = gpg.getMultiplayerInterface();
*
* SocialGooglePlayGames.login(function(loggedIn, error) {
* if(loggedIn){
* var request = new Cocoon.Multiplayer.MatchRequest(2,2);
* var handleMatch = function(match, error){
*
* }
* ...
* MultiplayerGooglePlayGames.findMatch(request, handleMatch);
* ...
* }
* });
*/
Cocoon.define("Cocoon.Multiplayer", function(extension) {
extension.GooglePlayGames = new Cocoon.Multiplayer.MultiplayerService('LDMultiplayerGPGPlugin');
/**
* Presents a system View for the matchmaking and creates a new Match.
* @function findMatch
* @memberOf Cocoon.Multiplayer.GooglePlayGames
* @param {Cocoon.Multiplayer.MatchRequest} matchRequest The parameters for the match.
* @param {Function} callback The callback function. It receives the following parameters:
* - {@link Cocoon.Multiplayer.Match}.
* - Error.
*/
/**
* Sends an automatch request to join the authenticated user to a match. It doesn't present a system view while waiting to other players.
* @function findAutoMatch
* @memberOf Cocoon.Multiplayer.GooglePlayGames
* @param {Cocoon.Multiplayer.MatchRequest} matchRequest The parameters for the match.
* @param {Function} callback The callback function. It receives the following parameters:
* - {@link Cocoon.Multiplayer.Match}.
* - Error.
*/
/**
* Cancels the ongoing automatch request.
* @function cancelAutoMatch
* @memberOf Cocoon.Multiplayer.GooglePlayGames
*/
/**
* Automatically adds players to an ongoing match owned by the user.
* @function addPlayersToMatch
* @memberOf Cocoon.Multiplayer.GooglePlayGames
* @param {Cocoon.Multiplayer.MatchRequest} matchRequest The parameters for the match.
* @param {Cocoon.Multiplayer.Match} matchRequest The match where new players will be added.
* @param {Function} callback The callback function. Response parameters: error.
*/
/**
* Get the current match reference.
* @function getMatch
* @memberOf Cocoon.Multiplayer.GooglePlayGames
* @return {Cocoon.Multiplayer.Match} The current match reference.
*/
return extension;
});
})();