supersockets扩展服务器配置
关键字: 扩展配置, 自定义配置, 自定义属性, GetChildConfig, 读取配置,子节点
当你使用 SuperSocket 实现 Socket 服务器的时候,不可避免的需要在配置文件中定义一些参数。 SuperSocket 提供了非常简单的方法,让你在配置文件中定义这些参数,然后在你的代码中读取它们。
请看下面的配置代码:
<server name="FlashPolicyServer"
serverType="SuperSocket.Facility.PolicyServer.FlashPolicyServer, SuperSocket.Facility"
ip="Any" port="843"
receiveBufferSize="32"
maxConnectionNumber="100"
clearIdleSession="true"
policyFile="Policy\flash.xml">
</server>
在上面的配置中, 属性 "policyFile" 未在 SuperSocket 中定义, 不过你任然可以在你的 AppServer 类中读取它:
public class YourAppServer : AppServer
{
private string m_PolicyFile;
protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
{
m_PolicyFile = config.Options.GetValue("policyFile");
if (string.IsNullOrEmpty(m_PolicyFile))
{
if(Logger.IsErrorEnabled)
Logger.Error("Configuration option policyFile is required!");
return false;
}
return true;
}
}
你不仅可以在 server 节点定义属性, 而且你还能像下面的代码那样定义子节点:
<server name="SuperWebSocket"
serverTypeName="SuperWebSocket"
ip="Any" port="2011" mode="Tcp">
<subProtocols>
<!--Your configuration-->
</subProtocols>
</server>
下面是所需的节点对应的配置类:
/// <summary>
/// SubProtocol configuration
/// </summary>
public class SubProtocolConfig : ConfigurationElement
{
//Configuration attributes
}
/// <summary>
/// SubProtocol configuation collection
/// </summary>
[ConfigurationCollection(typeof(SubProtocolConfig))]
public class SubProtocolConfigCollection : ConfigurationElementCollection
{
//Configuration attributes
}
然后你就能在 AppServer 类中读取这个子节点了:
public class YourAppServer : AppServer
{
private SubProtocolConfigCollection m_SubProtocols;
protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
{
m_SubProtocols = config.GetChildConfig<SubProtocolConfigCollection>("subProtocols");
if (m_SubProtocols == null)
{
if(Logger.IsErrorEnabled)
Logger.Error("The child configuration node 'subProtocols' is required!");
return false;
}
return true;
}
}
supersockets扩展服务器配置的更多相关文章
- about Red_Hat_Enterprise_Linux_7
systemd systemd 是 Linux 的系统和服务管理程序,替换了 Red Hat Enterprise Linux 之前的发行本中使用的 SysV.systemd 与 SysV 和 Lin ...
- supersockets服务器配置热更新
Keywords: 配置,热更新 此功能能够允许你在不重启服务器的前提下更新服务器实例的配置. (仅限1.6.5及其以上版本)
- PHP-Redis扩展使用手册(一)
//初始化redis实例 $redis = new Redis(); /* connect . open 链接redis * @param string host redis服务器地址 * @para ...
- Dynamics AX 2012 R2 安装Reporting Services 扩展
今天Reinhard在VS中部署SSRS报表时,接到以下错误: 部署因错误而被取消.在报表服务器上,验证:-SQL Server Reporting Services 服务是否正在运行. 接着,Rei ...
- Centos安装Memcached和(Nginx)Memcache扩展详细教程
下载memadmin,下载地址:http://www.junopen.com/memadmin/ 并在IIS新建站点. 测试地址:http://wap.yousawang.com/mem , 1.重启 ...
- 【T电商 3】Nginx的Http(图片)服务器配置+ftp上传使用说明
在前两篇博客中提到了搭建Nginx和Ftp服务器,在本篇博客,主要是介绍Nginx的配置文件的使用,怎样修改配置文件使其成为一个图片服务器. 一.Nginx图片服务器配置 <span style ...
- Win2003_IIS+PHP+MYSQL 全能服务器配置
WIN2003_IIS+PHP+mysql最新版_全能服务器配置 本次配置PHP的服务器环境:Windows2003+IIS6+ASP+PHP5+MySQL5整个配置过程需要是使用拥有管理员权限的系统 ...
- ssh2 php扩展
如何通过PHP启动和关闭远程服务器上的某个软件,譬如Memcached.对于俺这个刚刚掌握PHP编程皮毛的菜鸟来说,最直接不过的想法就是用exec函数执行SSH命令呗,先把运行Apache+PHP的服 ...
- SmartWiki开发日记之Laravel缓存扩展
SmartWiki简介请阅读: http://www.cnblogs.com/lifeil/p/6113323.html 因为SmartWiki的演示站点部署在阿里云上,阿里云有一个128M免费的Me ...
随机推荐
- Data Lake Analytics IP白名单设置攻略
当我们成功开通了 DLA 服务之后,第一个最想要做的事情就是登录 DLA 数据库.而登录数据库就需要一个连接串.下面这个页面是我们首次开通 DLA 之后的界面,在这里我们要创建一个服务访问点. 在上面 ...
- Calendar to julian date format
1.JULIAN DATE 定义 2.示例: 定义枚举: public enum JulianDateType { /// <summary> /// J ...
- ML面试1000题系列(71-80)
本文总结ML面试常见的问题集 转载来源:https://blog.csdn.net/v_july_v/article/details/78121924 71.看你是搞视觉的,熟悉哪些CV框架,顺带聊聊 ...
- Android学习笔记之mainfest文件中android属性
android:allowTaskReparenting 是否允许activity更换从属的任务,比如从短信息任务 切换到浏览器任务. -------------------------------- ...
- 用Direct2D和DWM来做简单的动画效果
原文:用Direct2D和DWM来做简单的动画效果 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sunnyloves/article/detail ...
- 【有用】rn-viewpager中的IndicatorViewPager
实现引导页滑动 //js/pages/GuidePage.js import {StyleSheet, View, Button, Text, Image, TouchableOpacity,Asyn ...
- CSS浏览器兼容解决方案
1.在ie8的甑别上,如何让样式只对ie8起作用? 用ie浏览器独有的文档注释的方式.像这样: <!DOCTYPE html> <!--> <html class=&qu ...
- 【JZOJ4791】【NOIP2016提高A组模拟9.21】矩阵
题目描述 在麦克雷的面前出现了一个有n*m个格子的矩阵,每个格子用"."或"#"表示,"."表示这个格子可以放东西,"#" ...
- 高速求幂 POW优化
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u013497151/article/details/27633731 #include <io ...
- c# 日期函数
DateTime dt = DateTime.Now;Label1.Text = dt.ToString();//2005-11-5 13:21:25Label2.Text = dt.ToFileTi ...