zoukankan      html  css  js  c++  java
  • QuickStart下的CommandFilter项目 github上自己修改过的版本

    http://docs.supersocket.net/v1-6/zh-CN/Command-Filter

    命令筛选的例子

    从CommandFilterAttribute派生出新的命令筛选类,然后将这些派生出来的类,放到命令类的上方[]

    最后在执行命令的时候会触发

    OnCommandExecuting 和OnCommandExecuted方法,这2个方法需要在派生类中重写

    具体分析:

    首先一个Server类

    [CountCommandFilter]//Global command filter
    public class MyAppServer : AppServer<MyAppSession>

    然后有2个命令类

    [LogTimeCommandFilter]

    public class LOGIN : StringCommandBase<MyAppSession>

    [LoggedInValidationFilter(Order = 0)]
    [LogTimeCommandFilter(Order = 1)]

    public class QUERY : StringCommandBase<MyAppSession>

    然后有3个命令筛选类

     public class CountCommandFilter : CommandFilterAttribute

    public class LoggedInValidationFilter : CommandFilterAttribute

     public class LogTimeCommandFilter : CommandFilterAttribute

    其中CountCommandFilter 作为全局的命令筛选
    LOGIN 有一个显式的命令筛选[LogTimeCommandFilter]

    Query有2个显式的命令筛选[LoggedInValidationFilter(Order = 0)]和[LogTimeCommandFilter(Order = 1)]

    它们都具有隐式的全局命令筛选CountCommandFilter 

    所以最后在执行命令的时候:

    Login命令只会触发2个命令筛选

    而Query命令会触发3个命令筛选

  • 相关阅读:
    结果可视化——Matplotlib.pyplot
    退役后的分治练习
    RNN姓氏分类:官方教程翻译
    libtorch使用笔记
    俄罗斯方块
    Flask使用笔记
    JQuery入门笔记
    glibc升级小记
    cvm母机宕机重启后数据库修复
    借用smtp.qq.com发邮件
  • 原文地址:https://www.cnblogs.com/chucklu/p/4348760.html
Copyright © 2011-2022 走看看