This namespace provides an abstraction API for a local loopback service that emulates the bahaviour of a multiplayer service. This service can be very helpful during the development process to setup the login before integrating any other multiplayer service.
Example
var loopback = new Cocoon.Multiplayer.LoopbackService(); var request = new Cocoon.Multiplayer.MatchRequest(2,2); var handleMatch = function(match, error){ } ... loopback.findMatch(request, handleMatch); ...
Methods
-
<static> addPlayersToMatch(matchRequest, matchRequest, callback)
-
Automatically adds players to an ongoing match owned by the user.
Parameters:
Name Type Description matchRequest
Cocoon.Multiplayer.MatchRequest The parameters for the match.
matchRequest
Cocoon.Multiplayer.Match The match where new players will be added.
callback
function The callback function. Response parameters: error.
-
<static> cancelAutoMatch()
-
Cancels the ongoing automatch request.
-
<static> findAutoMatch(matchRequest, callback)
-
Sends an automatch request to join the authenticated user to a match. It doesn't present a system view while waiting to other players.
Parameters:
Name Type Description matchRequest
Cocoon.Multiplayer.MatchRequest The parameters for the match.
callback
function The callback function. It receives the following parameters:
- Cocoon.Multiplayer.Match.
- Error.
-
<static> findMatch(matchRequest, callback)
-
Presents a system View for the matchmaking and creates a new Match.
Parameters:
Name Type Description matchRequest
Cocoon.Multiplayer.MatchRequest The parameters for the match.
callback
function The callback function. It receives the following parameters:
- Cocoon.Multiplayer.Match.
- Error.
-
<static> getMatch() → {Cocoon.Multiplayer.Match}
-
Get the current match reference.
Returns:
The current match reference.