Client ~ CacheInterface Schema - UofM-COMP4350-4/NBGI GitHub Wiki

Draft 1

Interface to easily store user/game data formats into a cache for easily retrieval at a later date.

Component API

saveGameCache(instance, gameBoard)

  • instance {Number} - Instance ID of the match chatroom
  • gameBoard {Object} - Current gameboard state, in the format:
{
    instanceID:0, // {Number} - Instance ID for match gameboard data
    gameID:0, // {Number} - Type of game the game is
    userToPlay:0, // {String} - User ID whose turn it is
    players: { // {Object} -  JSON of userID:userName pairs.
        <userID>:"", // {String} - <userID> is the {String} value of the userID number
                                // and returns the displayable username
        ... // Repeating the userID:userName format for each player
    },
    currentBoard: { // {Object} - JSON of pieceID:piecePosition pairs.
        <pieceID>: { // {Object} - <pieceID> is the {String} value of the pieceID
            pos: { // {Object} - Position data for the piece
                x:0, // {Number} - Board x-coordinate position number
                y:0, // OPTIONAL {Number} - Board y-coordinate position number
                z:0 // OPTIONAL {Number} - Board z-coordinate position number
            }
        },
        ... // Repeating the pieceID:piecePosition format for each piece on the board
    },
    status: undefined // {Object} - Any extra game-specific board data passed; undefined if none
}

loadGameCache(instance, fn)

  • instance {Number} - Instance ID of the match chatroom

  • fn {Function(gameBoard)} - A callback function that is called once the gameboard state cache is retrieved

    • gameBoard {Object} - Cached gameboard state (see above)

saveChatLogCache(instance, chatData)

  • instance {Number} - Instance ID of the match chatroom
  • chatData {Array} - List of received messages, in order, each in the format:
{
    userName:"", // {String} - Displayable username that sent the message
    text:"" // {String} - Text chat message content
}

loadChatLogCache(instance, fn)

  • instance {Number} - Instance ID of the match chatroom

  • fn {Function(chatData)} - A callback function that is called once the chat log cache is retrieved

    • chatData {Array} - List of received messages, in order, each in the format:
{
    userName:"", // {String} - Displayable username that sent the message
    text:"" // {String} - Text chat message content
}

saveProfileCache(profileData)

  • profileData {Object} - Logged-in user profile, in the format:
{
    userID:"", // {Number} - User ID of the friend
    userName:"", // {String} - Displayable username of the friend
    avatarURL:"" // {String} - Displayable user avatar path
    statistics: undefined // {Object} - User statistics information; TBD
}

loadProfileCache(fn)

  • fn {Function(profileData)} - A callback function that is called once the friends-list cache is retrieved

    • profileData {Object} - Logged-in user profile, in the format:
{
    userID:"", // {Number} - User ID of the friend
    userName:"", // {String} - Displayable username of the friend
    avatarURL:"" // {String} - Displayable user avatar path
    statistics: undefined // {Object} - User statistics information; TBD
}

saveFrendsCache(friendsData)

  • friendsData {Array} - List of friends, each in the format:
{
    userID:"", // {Number} - User ID of the friend
    userName:"", // {String} - Displayable username of the friend
    avatarURL:"" // {String} - Displayable user avatar path
}

loadFriendsCache(fn)

  • fn {Function(friendsData)} - A callback function that is called once the friends-list cache is retrieved

    • friendsData {Array} - List of friends, each in the format:
{
    userID:"", // {Number} - User ID of the friend
    userName:"", // {String} - Displayable username of the friend
    avatarURL:"" // {String} - Displayable user avatar path
}
⚠️ **GitHub.com Fallback** ⚠️