Class InMemoryPlayerDatabase
An In-Memory variant for the AbstractPlayerDatabase.
This is useful when you have an external identity provider or external database that is hosted separately from the core game.
Consider the following scenario:
You have a game and an API layer that handles authentication where all user identites are stored. You do not want to host a new database for the chat system itself.
In this case you would use this class and hydrate the InMemoryPlayerDatabase (which is only available on the server anyway) after API calls are made to figure out the user id
and the player's channels, friends list, and block list.
To hydrate this class you simply add a player still with AddPlayer(). Instead of running queries to the database to figure out data, this keeps all player information in a Dictionary at runtime.
Inheritance
System.Object
InMemoryPlayerDatabase
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: LlamaSoftware.Chat.dll
Syntax
public class InMemoryPlayerDatabase : AbstractPlayerDatabase<InMemoryPlayerDatabase>
Methods
FindBlockedPlayersFor(String)
Declaration
public override List<Player> FindBlockedPlayersFor(string PlayerId)
Parameters
Type |
Name |
Description |
System.String |
PlayerId |
|
Returns
Type |
Description |
System.Collections.Generic.List<Player> |
|
Overrides
LlamaSoftware.Chat.AbstractPlayerDatabase<LlamaSoftware.Chat.InMemoryPlayerDatabase>.FindBlockedPlayersFor(System.String)
FindFriendsFor(String)
Declaration
public override List<Player> FindFriendsFor(string PlayerId)
Parameters
Type |
Name |
Description |
System.String |
PlayerId |
|
Returns
Type |
Description |
System.Collections.Generic.List<Player> |
|
Overrides
LlamaSoftware.Chat.AbstractPlayerDatabase<LlamaSoftware.Chat.InMemoryPlayerDatabase>.FindFriendsFor(System.String)
FindPlayersWhoAreBlockedBy(String)
This is limited to only online players, which generally is fine since it is used to filter who to send messages to.
Offline players cannot receive messages anyway.
Declaration
public override List<Player> FindPlayersWhoAreBlockedBy(string PlayerId)
Parameters
Type |
Name |
Description |
System.String |
PlayerId |
|
Returns
Type |
Description |
System.Collections.Generic.List<Player> |
|
Overrides
LlamaSoftware.Chat.AbstractPlayerDatabase<LlamaSoftware.Chat.InMemoryPlayerDatabase>.FindPlayersWhoAreBlockedBy(System.String)
FindPlayersWhoHaveFriend(String)
This is limited to only online players. This should generally be fine since we use it for notifications.
Offline players cannot receive notifications.
Declaration
public override List<Player> FindPlayersWhoHaveFriend(string PlayerId)
Parameters
Type |
Name |
Description |
System.String |
PlayerId |
|
Returns
Type |
Description |
System.Collections.Generic.List<Player> |
|
Overrides
LlamaSoftware.Chat.AbstractPlayerDatabase<LlamaSoftware.Chat.InMemoryPlayerDatabase>.FindPlayersWhoHaveFriend(System.String)
FindSubscribedChannelsFor(String)
This is limited to only online players. This should generally be fine since we use it only for online players.
Offline players cannot get their subscribed channels.
Declaration
public override List<ChatChannel> FindSubscribedChannelsFor(string PlayerId)
Parameters
Type |
Name |
Description |
System.String |
PlayerId |
|
Returns
Type |
Description |
System.Collections.Generic.List<ChatChannel> |
|
Overrides
LlamaSoftware.Chat.AbstractPlayerDatabase<LlamaSoftware.Chat.InMemoryPlayerDatabase>.FindSubscribedChannelsFor(System.String)
SavePlayerChatSettings(Player)
Simply updates the player in the KnownPlayerSubscriptions.
Depending on your game's needs, you may make an API call here to update your database, or do whatever you need to do to update your source of truth.
If you do not persist the changes by the player (passed in as "Player") then the next time the user logs in they will not know their new friends, blocked players, or chat channels.
Declaration
public override void SavePlayerChatSettings(Player Player)
Parameters
Type |
Name |
Description |
Player |
Player |
Fully qualified updated player
|
Overrides
LlamaSoftware.Chat.AbstractPlayerDatabase<LlamaSoftware.Chat.InMemoryPlayerDatabase>.SavePlayerChatSettings(LlamaSoftware.Chat.Model.Player)