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
    本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
  • 相关阅读:
    ubuntu 下redis的安装简介
    Oracle 的几种循环方式介绍
    NIO 概述 与 通信实例
    io 的一些简单说明及使用
    webSocket的 原理 及 实现
    事务 与事务的 隔离级别 简单说明
    case 函数的简单使用记录下
    java HttpClient 忽略证书的信任的实现 MySSLProtocolSocketFactory
    南京小吃八绝
    JavaScript图表库(百度)
  • 原文地址:https://www.cnblogs.com/jzywh/p/2036919.html
Copyright © 2011-2022 走看看