zoukankan      html  css  js  c++  java
  • SuperSocket 1.4系列文档(11) 扩展服务器配置

    实现自己的Socket服务器,不免需要将某些参数放到配置文件之中。而SuperSocket提供了非常好用的接口让你将参数存入配置文件之中并且在你AppServer中能够方便的读取和使用。

    如下配置代码:

       1: <server name="FlashPolicyServer"
       2:         serviceName="FlashPolicyService"
       3:         ip="Any" port="843"
       4:         mode="Async"
       5:         receiveBufferSize="32"
       6:         maxConnectionNumber="100"        
       7:         clearIdleSession="true"
       8:         policyFile="Policy\flash.xml">
       9: </server>

    上面配置文件之中,server节点的最后一个属性policyFile="Policy\flash.xml"并非SuperSocket的内置配置属性,而是一个扩展属性。而这个扩展属性可以在你的AppServer类的重载Setup方法中读取,如下代码:

       1: public abstract class PolicyServer : AppServer<PolicySession, BinaryCommandInfo>
       2: {
       3:     private string m_PolicyFile;
       4:  
       5:     public PolicyServer()
       6:         : base()
       7:     {
       8:  
       9:     }
      10:  
      11:     public override bool Setup(IRootConfig rootConfig,
      12:                                IServerConfig config,
      13:                                ISocketServerFactory socketServerFactory,
      14:                                ICustomProtocol<BinaryCommandInfo> protocol)
      15:     {            
      16:         if (!base.Setup(rootConfig, config, socketServerFactory, protocol))
      17:             return false;
      18:  
      19:         m_PolicyFile = config.Options.GetValue("policyFile");
      20:  
      21:         if (string.IsNullOrEmpty(m_PolicyFile))
      22:         {
      23:             Logger.LogError("Configuration option policyFile is required!");
      24:             return false;
      25:         }
      26:  
      27:         return true;
      28:     }
      29: }
    作者:江振宇
    出处:http://jzywh.cnblogs.com
    本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
  • 相关阅读:
    ansible-2添加公钥
    ansible-1 的安装
    history命令显示出详细时间
    nginx配置文件详解
    oracle-7参数文件的管理
    使用gitlab+jenkins+saltstack+rsync自动部署Web应用
    tomcat配置和优化
    pip --upgrade批量更新过期的python库
    apk下载安装,存储的位置,路径
    android中的内部存储与外部存储
  • 原文地址:https://www.cnblogs.com/jzywh/p/2036919.html
Copyright © 2011-2022 走看看