Class WolfClientCache
Utility grouping common entity caches together.
Namespace: TehGM.Wolfringo.Caching.Internal
Assembly: Wolfringo.Core.dll
Syntax
public class WolfClientCache : IWolfClientCache, IWolfClientCacheAccessor, IDisposable
Remarks
This utility contains caches for entities that Wolf client is caching.
Each cache can be separately enabled or disabled.
Constructors
| Improve this Doc View SourceWolfClientCache(ILogger)
Creates new container and contained caches with all caches enabled.
Declaration
public WolfClientCache(ILogger log = null)
Parameters
Type | Name | Description |
---|---|---|
ILogger | log | Logger that this cache can log to. If null, logging will be disabled. |
Remarks
All caches will be enabled by default.
WolfClientCache(WolfCacheOptions, ILogger)
Creates new container and contained caches.
Declaration
public WolfClientCache(WolfCacheOptions options, ILogger log = null)
Parameters
Type | Name | Description |
---|---|---|
WolfCacheOptions | options | Options specifying which caches should be enabled. |
ILogger | log | Logger that this cache can log to. If null, logging will be disabled. |
WolfClientCache(WolfCacheOptions, ILogger<WolfClientCache>)
Creates new container and contained caches.
Declaration
public WolfClientCache(WolfCacheOptions options, ILogger<WolfClientCache> log)
Parameters
Type | Name | Description |
---|---|---|
WolfCacheOptions | options | Options specifying which caches should be enabled. |
ILogger<WolfClientCache> | log | Logger that this cache can log to. If null, logging will be disabled. |
Properties
| Improve this Doc View SourceAchievementsCache
Achievements cache.
Declaration
protected IWolfCachedEntityCollection<WolfLanguage, WolfAchievement> AchievementsCache { get; }
Property Value
Type | Description |
---|---|
IWolfCachedEntityCollection<WolfLanguage, WolfAchievement> |
CharmsCache
Charms cache.
Declaration
protected IWolfCachedEntityCollection<WolfCharm> CharmsCache { get; }
Property Value
Type | Description |
---|---|
IWolfCachedEntityCollection<WolfCharm> |
GroupsCache
Groups cache.
Declaration
protected IWolfCachedEntityCollection<WolfGroup> GroupsCache { get; }
Property Value
Type | Description |
---|---|
IWolfCachedEntityCollection<WolfGroup> |
IsAchievementsCachingEnabled
Whether caching of WolfAchievement is enabled.
Declaration
public bool IsAchievementsCachingEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsCharmsCachingEnabled
Whether caching of WolfCharm is enabled.
Declaration
public bool IsCharmsCachingEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsGroupsCachingEnabled
Whether caching of WolfGroup is enabled.
Declaration
public bool IsGroupsCachingEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsUsersCachingEnabled
Whether caching of WolfUser is enabled.
Declaration
public bool IsUsersCachingEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
Log
A logger for logging messages.
Declaration
protected ILogger Log { get; }
Property Value
Type | Description |
---|---|
ILogger |
UsersCache
Users cache.
Declaration
protected IWolfCachedEntityCollection<WolfUser> UsersCache { get; }
Property Value
Type | Description |
---|---|
IWolfCachedEntityCollection<WolfUser> |
Methods
| Improve this Doc View SourceClear()
Clears all caches.
Declaration
public virtual void Clear()
GetCachedAchievement(WolfLanguage, UInt32)
Get achievement from cache.
Declaration
public WolfAchievement GetCachedAchievement(WolfLanguage language, uint id)
Parameters
Type | Name | Description |
---|---|---|
WolfLanguage | language | Language of achievement's translations. |
UInt32 | id | ID of the achievement. |
Returns
Type | Description |
---|---|
WolfAchievement | Cached achievement if found in requested language; otherwise null. |
GetCachedCharm(UInt32)
Get charm from cache.
Declaration
public WolfCharm GetCachedCharm(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | ID of the charm. |
Returns
Type | Description |
---|---|
WolfCharm | Cached charm if found; otherwise null. |
GetCachedGroup(String)
Get group from cache.
Declaration
public WolfGroup GetCachedGroup(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of the group. |
Returns
Type | Description |
---|---|
WolfGroup | Cached group if found; otherwise null. |
GetCachedGroup(UInt32)
Get group from cache.
Declaration
public WolfGroup GetCachedGroup(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | ID of the group. |
Returns
Type | Description |
---|---|
WolfGroup | Cached group if found; otherwise null. |
GetCachedUser(UInt32)
Get user from cache.
Declaration
public WolfUser GetCachedUser(uint id)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | id | ID of the user. |
Returns
Type | Description |
---|---|
WolfUser | Cached user if found; otherwise null. |
LogWarning(String, Object[])
Logs message with Warning level, and returns true.
Declaration
protected bool LogWarning(string message, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
String | message | Log message template. |
Object[] | args | Structured log message arguments. |
Returns
Type | Description |
---|---|
Boolean | True. |
Remarks
Designed to use with catch (Exception) when
pattern. Preserves log scope for logged message.
OnConnectingAsync(IWolfClient, CancellationToken)
Invoked when client is about to connect to the server.
Declaration
public virtual Task OnConnectingAsync(IWolfClient client, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | WOLF client that is connecting to the server. |
CancellationToken | cancellationToken | Cancellation token that can be used for Task cancellation. |
Returns
Type | Description |
---|---|
Task |
OnDisconnected(IWolfClient, SocketClosedEventArgs)
Invoked when the client has disconnected from the server.
Declaration
public virtual void OnDisconnected(IWolfClient client, SocketClosedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | WOLF client that has disconnected from the server. |
SocketClosedEventArgs | e | Event args raised when connection was closed. |
OnMessageReceivedAsync(IWolfClient, IWolfMessage, SerializedMessageData, CancellationToken)
Handle message received from the server.
Declaration
public virtual async Task OnMessageReceivedAsync(IWolfClient client, IWolfMessage message, SerializedMessageData rawMessage, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | WOLF client that received the message. |
IWolfMessage | message | Received message. |
SerializedMessageData | rawMessage | Raw received message. |
CancellationToken | cancellationToken | Cancellation token that can be used for Task cancellation. |
Returns
Type | Description |
---|---|
Task |
OnMessageSentAsync(IWolfClient, IWolfMessage, IWolfResponse, SerializedMessageData, CancellationToken)
Handle message sent by the client, and the server's response.
Declaration
public virtual Task OnMessageSentAsync(IWolfClient client, IWolfMessage message, IWolfResponse response, SerializedMessageData rawResponse, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWolfClient | client | WOLF client that sent the message. |
IWolfMessage | message | Sent message. |
IWolfResponse | response | Response received. |
SerializedMessageData | rawResponse | Raw response data. |
CancellationToken | cancellationToken | Cancellation token that can be used for Task cancellation. |
Returns
Type | Description |
---|---|
Task |
Explicit Interface Implementations
| Improve this Doc View SourceIDisposable.Dispose()
Declaration
void IDisposable.Dispose()