Leaderboard
 
Loading...
Searching...
No Matches
Noble.Leaderboard.Leaderboard Class Reference

The Leaderboard plugin used to create, retrieve, or delete highscore entries. More...

Inherits MonoBehaviour.

Public Member Functions

async Task AddEntry (string playerName, int score, string levelName, byte[] metadata=null, int maxEntriesPerPlayer=5, bool sortAsc=false)
 Used to add a highscore entry to the leaderboard. More...
 
async Task< List< ReceivedEntry > > GetList (string levelName, string playerName=null, int startingIndex=0, int displayedEntries=10, bool allowDuplicateEntries=false, bool sortAsc=false)
 Used to retrieve a list of highscore entries. More...
 
async Task< List< ReceivedEntry > > GetListAdjacent (string levelName, string playerName, int playerScore, int adjacentEntries=2, bool allowDuplicateEntries=false, bool sortAsc=false)
 Used to retrieve adjacent highscore entries. More...
 
async Task DeleteByPlayerAndLevel (string levelName, string playerName)
 Used to remove entries defined by the given level name and player name from the leaderboard. More...
 
async Task DeleteByPlayer (string playerName)
 Used to remove entries defined by the given player name from the leaderboard. More...
 
async Task DeleteByLevel (string levelName)
 Used to remove entries defined by the given level name from the leaderboard. More...
 
async Task DeleteAll ()
 Used to remove all entries from the leaderboard. More...
 

Static Public Attributes

const int MAX_ENTRIES_TO_RETURN_AT_ONCE = 20
 The maximum number of entries that can be returned in one request
 
const int MAX_METADATA_SIZE = 1024 * 10
 The maximum size of meta data that is allowed per entry
 
const int MAX_STRING_LENGTH = 45
 The maximum length of username and level name string
 
const int MAX_BYTES_PER_CHARACTER = 4
 All strings are utf-8 encoded so each character can at most take 4 bytes to encode
 
const int MAX_STRING_BYTES = MAX_BYTES_PER_CHARACTER * MAX_STRING_LENGTH
 The maximum byte length for the username and level name strings
 
const int READ_BUFFER_SIZE = MAX_ENTRIES_TO_RETURN_AT_ONCE * (MAX_METADATA_SIZE + MAX_STRING_BYTES + MAX_STRING_BYTES + 4 * 5)
 The size of a single read buffer. This is the maximum number of bytes a client can send in a single request. More...
 

Properties

bool HasActiveRequest [get]
 Checks to see if you are currently waiting on a response from the server. More...
 

Detailed Description

The Leaderboard plugin used to create, retrieve, or delete highscore entries.

Member Function Documentation

◆ AddEntry()

async Task Noble.Leaderboard.Leaderboard.AddEntry ( string  playerName,
int  score,
string  levelName,
byte[]  metadata = null,
int  maxEntriesPerPlayer = 5,
bool  sortAsc = false 
)
inline

Used to add a highscore entry to the leaderboard.

If a player has reached the maximum entry limit then the lowest score will automatically be deleted by default. If sorting by ascending the highest score will be deleted instead.

Parameters
playerNameThe name of the player associated with the entry to add.
scoreThe score of the player associated with the entry to add.
levelNameThe name of the level associated with the entry to add.
metadataAny other relevant information associated with the entry to add.
maxEntriesPerPlayerThe maximum amount of entries allowed per player.
sortAscDetermines sort order and rank order in the case that low scores are considered better.
Returns
A task that you can await to know when the request has been completed.
Exceptions
AccessViolationExceptionThrown if the game ID is not valid.

◆ DeleteAll()

async Task Noble.Leaderboard.Leaderboard.DeleteAll ( )
inline

Used to remove all entries from the leaderboard.

Returns
A task that you can await to know when the request has been completed.

◆ DeleteByLevel()

async Task Noble.Leaderboard.Leaderboard.DeleteByLevel ( string  levelName)
inline

Used to remove entries defined by the given level name from the leaderboard.

Parameters
levelNameThe name of the level defining which entries to remove.
Returns
A task that you can await to know when the request has been completed.

◆ DeleteByPlayer()

async Task Noble.Leaderboard.Leaderboard.DeleteByPlayer ( string  playerName)
inline

Used to remove entries defined by the given player name from the leaderboard.

Parameters
playerNameThe name of the player defining which entries to remove.
Returns
A task that you can await to know when the request has been completed.

◆ DeleteByPlayerAndLevel()

async Task Noble.Leaderboard.Leaderboard.DeleteByPlayerAndLevel ( string  levelName,
string  playerName 
)
inline

Used to remove entries defined by the given level name and player name from the leaderboard.

Parameters
levelNameThe name of the level defining which entries to remove.
playerNameThe name of the player defining which entries to remove.
Returns
A task that you can await to know when the request has been completed.

◆ GetList()

async Task< List< ReceivedEntry > > Noble.Leaderboard.Leaderboard.GetList ( string  levelName,
string  playerName = null,
int  startingIndex = 0,
int  displayedEntries = 10,
bool  allowDuplicateEntries = false,
bool  sortAsc = false 
)
inline

Used to retrieve a list of highscore entries.

Parameters
levelNameThe name of the level associated with the entries to return.
playerNameThe name of the player associated with the entries to return.
startingIndexThe index of the first entry in the list to return.
displayedEntriesThe amount of entries in the list to return.
allowDuplicateEntriesWhether or not to return multiple entries from a user in the list.
sortAscDetermines sort order and rank order in the case that low scores are considered better.
Returns
The list of received entries.
Exceptions
AccessViolationExceptionThrown if the game ID is not valid.

◆ GetListAdjacent()

async Task< List< ReceivedEntry > > Noble.Leaderboard.Leaderboard.GetListAdjacent ( string  levelName,
string  playerName,
int  playerScore,
int  adjacentEntries = 2,
bool  allowDuplicateEntries = false,
bool  sortAsc = false 
)
inline

Used to retrieve adjacent highscore entries.

Returns the scores adjacent to the entry defined by the level name, player name, and player score.

Parameters
levelNameThe name of the level defining which entries to return.
playerNameThe name of the player defining which entries to return.
playerScoreThe score of the player defining which entries to return.
adjacentEntriesThe amount of entries on either side of the defining entry to return.
allowDuplicateEntriesWhether or not to return multiple entries from a user in the list.
sortAscDetermines sort order and rank order in the case that low scores are considered better.
Returns
The list of received entries.
Exceptions
AccessViolationExceptionThrown if the game ID is not valid.

Member Data Documentation

◆ READ_BUFFER_SIZE

const int Noble.Leaderboard.Leaderboard.READ_BUFFER_SIZE = MAX_ENTRIES_TO_RETURN_AT_ONCE * (MAX_METADATA_SIZE + MAX_STRING_BYTES + MAX_STRING_BYTES + 4 * 5)
static

The size of a single read buffer. This is the maximum number of bytes a client can send in a single request.

45 comes from (player name length, level name length, score, client id, and message length) which are all 4 bytes each.

Property Documentation

◆ HasActiveRequest

bool Noble.Leaderboard.Leaderboard.HasActiveRequest
get

Checks to see if you are currently waiting on a response from the server.

You may only have one active request at a time.