dispatcherfilter.cs

来自「破解的飞信源代码」· CS 代码 · 共 81 行

CS
81
字号
namespace NCindy.Filter
{
    using NCindy;
    using NCindy.Session.Dispatcher;
    using System;

    public class DispatcherFilter : ISessionFilter
    {
        private readonly IDispatcher dispatcher;

        public DispatcherFilter(IDispatcher dispatcher)
        {
            this.dispatcher = dispatcher;
        }

        public void ExceptionCaught(ISessionFilterChain filterChain, Exception cause)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
            });
        }

        public void ObjectReceived(ISessionFilterChain filterChain, object obj)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.ObjectReceived(obj);
            });
        }

        public void ObjectSent(ISessionFilterChain filterChain, object obj)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.ObjectSent(obj);
            });
        }

        public void PacketReceived(ISessionFilterChain filterChain, IPacket packet)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.PacketReceived(packet);
            });
        }

        public void PacketSend(ISessionFilterChain filterChain, IPacket packet)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.PacketSend(packet);
            });
        }

        public void PacketSent(ISessionFilterChain filterChain, IPacket packet)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.PacketSent(packet);
            });
        }

        public void SessionStateChanged(ISessionFilterChain filterChain)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.SessionStateChanged();
            });
        }

        public void SessionTimeout(ISessionFilterChain filterChain)
        {
            this.dispatcher.Dispatch(filterChain.Session, delegate {
                filterChain.SessionTimeout();
            });
        }

        public IDispatcher Dispatcher
        {
            get
            {
                return this.dispatcher;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?