Matchmaking package cache server module.

ALPHA: This module and all underlying classes are currently in alpha.

Include in cache server with:

    loadModules([
      snipe.packages.matchmaking.CacheModule,
      ]);

Cache server configuration variables:

  • "packages/matchmaking.time" - timer delay in seconds between matchmaking checks. Equals 1 by default.

Methods

inline add (listID:String, user:MatchmakingUserClass):String

Adds this user to the specified matchmaking user list.

Note: A single user can only be in one matchmaking list. It will be automatically removed from other lists. If the user is added for the second time, his record will be replaced with the new one.

Parameters:

listID

Matchmaking list ID.

user

User data object. Has to have "id" and "__addedTime" fields.

Returns:

Operation error code. "ok" - operation was successful. "listNotFound" - list with this ID not found.

getCount (listID:String):Int

Returns the amount of users in the specified matchmaking user list.

Parameters:

listID

Matchmaking list ID.

Returns:

Amount of users in the list. Returns 0 if the list is not found.

registerType (params:{successPost:String ‑> MatchmakingUserClass ‑> MatchmakingUserClass ‑> Void, id:String, check:String ‑> MatchmakingUserClass ‑> MatchmakingUserClass ‑> Bool}):Void

Registers a new matchmaking list type.

Parameters:

params

List parameters. "id" - list ID, "check" - method to call for checking if a pair of users is matching. Should return true on success, false otherwise. "successPost" - method to call when a pair of users has been matched. It will be called from cache timer thread.

inline remove (listID:String, id:Int):String

Removes this user from the specified matchmaking user list.

Parameters:

listID

Matchmaking list ID.

id

User ID.

Returns:

Operation error code. "ok" - operation was successful. "listNotFound" - list with this ID not found.