Class MongoFIFOMatchmaker
- All Implemented Interfaces:
Matchmaker
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.getelements.elements.sdk.dao.Matchmaker
Matchmaker.Factory, Matchmaker.SuccessfulMatchTuple -
Field Summary
Fields inherited from interface dev.getelements.elements.sdk.dao.Matchmaker
DEFAULT_MAX_CANDIDATES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattemptToFindOpponent(Match match, int maxCandidatesToConsider, BiFunction<Match, Match, String> finalizer) Attempts to find an opponent for the suppliedMatchinstance.Returns theMatchingAlgorithmimplemented by this matchmaker.dev.morphia.DatastorevoidsetDatastore(dev.morphia.Datastore datastore) voidsetMongoMatchDao(MongoMatchDao mongoMatchDao) voidsetMongoMatchUtils(MongoMatchUtils mongoMatchUtils) Restricts thisMatchmakerto the supplied scope.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.sdk.dao.Matchmaker
attemptToFindOpponent
-
Constructor Details
-
MongoFIFOMatchmaker
public MongoFIFOMatchmaker()
-
-
Method Details
-
getAlgorithm
Description copied from interface:MatchmakerReturns theMatchingAlgorithmimplemented by this matchmaker.- Specified by:
getAlgorithmin interfaceMatchmaker- Returns:
- the
MatchingAlgorithm
-
attemptToFindOpponent
public Matchmaker.SuccessfulMatchTuple attemptToFindOpponent(Match match, int maxCandidatesToConsider, BiFunction<Match, Match, throws NoSuitableMatchExceptionString> finalizer) Description copied from interface:MatchmakerAttempts to find an opponent for the suppliedMatchinstance. This will query the database for suitable matches. This will return aMatchmaker.SuccessfulMatchTuplecombining the match of the player and the opponent's match.Thia also finalizes the matching process by flagging the
Matchinstances for deletion and invoking the finalizerSupplier<String>. The suppliedSupplier<String>returns a system-wide unique ID used to process to identify the game that was created as the result of theMatch. The return value of this method will be assigned to the match usingMatch.setGameId(String).Note that this method guarantees that the supplied
Supplier<String>finalizer will only ever be called once per successful matching tuple as multiple players may attempt to finalize the pairing at the same time. The return value indicates the affectedMatchinstances, or returns an emnpty stream if noMatchinstances were affected by the finalization.Because both players may not have read the
Match, the involvedMatchinstances will be marked for timeout and deletion at a later time.- Specified by:
attemptToFindOpponentin interfaceMatchmaker- Parameters:
match- theMatchthe player matchmaxCandidatesToConsider- the maximum number of candidates to considerfinalizer- theSupplierused to finalize the match and provide the resulting game id- Returns:
- a
Matchmaker.SuccessfulMatchTuplerepresenting a successful match, never null - Throws:
NoSuitableMatchException- if there is no suitable match found
-
withScope
Description copied from interface:MatchmakerRestricts thisMatchmakerto the supplied scope. Will return only whoseMatch.getScope()method matches the supplied scope. UnscopedMatchinstances will also be excluded from the candidate pool.- Specified by:
withScopein interfaceMatchmaker- Parameters:
scope- the scope- Returns:
- this instance
-
getDatastore
public dev.morphia.Datastore getDatastore() -
setDatastore
@Inject public void setDatastore(dev.morphia.Datastore datastore) -
getMongoMatchDao
-
setMongoMatchDao
-
getMongoMatchUtils
-
setMongoMatchUtils
-