Override Storage Methods
You can override all storage methods in the controller. For example you might add the Authorize attribute so that only clients that is authenticated can use storage methods.
The sample below only show the StorageSet
method, but you can also override StorageClear
, StorageGet
, StorageRemove
using XSockets.Core.XSocket;
using System.Threading.Tasks;
using XSockets.Core.XSocket.Model;
using XSockets.Core.Common.Socket.Attributes;
using XSockets.Plugin.Framework;
using XSockets.Core.Common.Utility.Logging;
public class Sample : XSocketController
{
[Authorize]
public override Task StorageSet(XStorage storage)
{
return base.StorageSet(storage);
}
public override Task OnAuthorizationFailure(string methodName)
{
Composable.GetExport<IXLogger>().Error("No access to {m}", methodName);
return base.OnAuthorizationFailure(methodName);
}
}
So calling StorageSet
without being authenticated will cause a error log like below.