📄 abstractsessionfilterchain.cs
字号:
namespace NCindy.Session
{
using NCindy;
using NCindy.Util.Logging;
using System;
public abstract class AbstractSessionFilterChain : ISessionFilterChain
{
private static readonly ILogger log = LogFactory.CreateLogger(MethodBase.GetCurrentMethod().ReflectedType);
private static readonly ISessionFilter NULL_FILTER = new NullFilter();
protected AbstractSessionFilterChain()
{
}
protected void CaughtException(Exception e)
{
this.Session.GetSessionFilterChain(FilterChainMode.Receive).ExceptionCaught(e);
}
public void ExceptionCaught(Exception cause)
{
try
{
this.Next().ExceptionCaught(this, cause);
}
catch (Exception exception)
{
if (log.IsWarnEnabled)
{
log.Warn("Exception caught failed.", exception);
}
}
}
private ISessionFilter Next()
{
ISessionFilter nextFilter = this.NextFilter;
if (nextFilter != null)
{
return nextFilter;
}
return NULL_FILTER;
}
public void ObjectReceived(object obj)
{
try
{
this.Next().ObjectReceived(this, obj);
}
catch (Exception exception)
{
this.CaughtException(exception);
}
}
public void ObjectSent(object obj)
{
try
{
this.Next().ObjectSent(this, obj);
}
catch (Exception exception)
{
this.CaughtException(exception);
}
}
public void PacketReceived(IPacket packet)
{
try
{
this.Next().PacketReceived(this, packet);
}
catch (Exception exception)
{
this.CaughtException(exception);
throw;
}
}
public void PacketSend(IPacket packet)
{
try
{
this.Next().PacketSend(this, packet);
}
catch (Exception exception)
{
this.CaughtException(exception);
}
}
public void PacketSent(IPacket packet)
{
try
{
this.Next().PacketSent(this, packet);
}
catch (Exception exception)
{
this.CaughtException(exception);
}
}
public void SessionStateChanged()
{
try
{
this.Next().SessionStateChanged(this);
}
catch (Exception exception)
{
this.CaughtException(exception);
}
}
public void SessionTimeout()
{
try
{
this.Next().SessionTimeout(this);
}
catch (Exception exception)
{
this.CaughtException(exception);
}
}
protected abstract ISessionFilter NextFilter { get; }
public abstract ISession Session { get; }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -