配置表接入和升级服务器框架到最新版
This commit is contained in:
37
Main/Fantasy.config
Normal file
37
Main/Fantasy.config
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<fantasy xmlns="http://fantasy.net/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://fantasy.net/config Fantasy.xsd">
|
||||
<!-- ~1~ 兼容模式:继续使用JSON配置表 @1@ -->
|
||||
<!-- <configTable path="./../../../Config/Json/Server/" /> -->
|
||||
<!-- 框架核心配置 -->
|
||||
<idFactory type="World" />
|
||||
<network inner="TCP" maxMessageSize="1048560" />
|
||||
<session idleTimeout="8000" idleInterval="5000" />
|
||||
<!-- 服务器拓扑结构 -->
|
||||
<server>
|
||||
<machines>
|
||||
<machine id="1" outerIP="127.0.0.1" outerBindIP="127.0.0.1" innerBindIP="127.0.0.1" />
|
||||
</machines>
|
||||
<processes>
|
||||
<process id="1" machineId="1" startupGroup="0" />
|
||||
</processes>
|
||||
<worlds>
|
||||
<world id="1" worldName="测试服" dbConnection="mongodb://127.0.0.1" dbName="fantasy_main" dbType="MongoDB" />
|
||||
</worlds>
|
||||
<scenes>
|
||||
<scene id="1001" processConfigId="1" worldConfigId="1" sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Addressable" networkProtocol="KCP" outerPort="20001" innerPort="11001" sceneType="1" />
|
||||
<scene id="1002" processConfigId="1" worldConfigId="1" sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Addressable" networkProtocol="" outerPort="0" innerPort="11011" sceneType="2" />
|
||||
<scene id="1003" processConfigId="1" worldConfigId="1" sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Gate" networkProtocol="KCP" outerPort="20000" innerPort="11021" sceneType="3" />
|
||||
<scene id="1004" processConfigId="1" worldConfigId="1" sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Game" networkProtocol="" outerPort="0" innerPort="11031" sceneType="4" />
|
||||
<scene id="1006" processConfigId="1" worldConfigId="1" sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Chat" networkProtocol="" outerPort="0" innerPort="11051" sceneType="8" />
|
||||
<scene id="1007" processConfigId="1" worldConfigId="1" sceneRuntimeMode="MultiThread"
|
||||
sceneTypeString="Map" networkProtocol="" outerPort="0" innerPort="11061" sceneType="5" />
|
||||
</scenes>
|
||||
</server>
|
||||
</fantasy>
|
||||
302
Main/Fantasy.xsd
Normal file
302
Main/Fantasy.xsd
Normal file
@@ -0,0 +1,302 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://fantasy.net/config"
|
||||
xmlns="http://fantasy.net/config"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<!-- Root element -->
|
||||
<xs:element name="fantasy">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Fantasy框架配置文件根元素</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="configTable" type="configTableType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>配置表路径设置</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="idFactory" type="idFactoryType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>ID生成器配置</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="network" type="networkRuntimeType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>网络运行时配置</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="session" type="sessionRuntimeType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>会话运行时配置</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="server" type="serverType" minOccurs="1" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>服务器配置</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<!-- ConfigTable type -->
|
||||
<xs:complexType name="configTableType">
|
||||
<xs:attribute name="path" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>配置表文件路径</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- IdFactory type -->
|
||||
<xs:complexType name="idFactoryType">
|
||||
<xs:attribute name="type" use="optional" default="World">
|
||||
<xs:annotation>
|
||||
<xs:documentation>ID生成器规则类型</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Default">
|
||||
<xs:annotation>
|
||||
<xs:documentation>默认生成器,Scene最大为65535个</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:enumeration>
|
||||
<xs:enumeration value="World">
|
||||
<xs:annotation>
|
||||
<xs:documentation>ID中包含World,可解决合区ID重复问题,但Scene数量限制到255个</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:enumeration>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Server type -->
|
||||
<xs:complexType name="serverType">
|
||||
<xs:sequence>
|
||||
<xs:element name="machines" type="machinesType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>机器配置列表</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="processes" type="processesType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>进程配置列表</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="worlds" type="worldsType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>世界配置列表</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="scenes" type="scenesType" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation>
|
||||
<xs:documentation>场景配置列表</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Machines types -->
|
||||
<xs:complexType name="machinesType">
|
||||
<xs:sequence>
|
||||
<xs:element name="machine" type="machineType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="machineType">
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>机器ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="outerIP" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>外网IP地址</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="outerBindIP" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>外网绑定IP地址</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="innerBindIP" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>内网绑定IP地址</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Processes types -->
|
||||
<xs:complexType name="processesType">
|
||||
<xs:sequence>
|
||||
<xs:element name="process" type="processType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="processType">
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>进程ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="machineId" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>所属机器ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="startupGroup" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>启动分组</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Worlds types -->
|
||||
<xs:complexType name="worldsType">
|
||||
<xs:sequence>
|
||||
<xs:element name="world" type="worldType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="worldType">
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>世界ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="worldName" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>世界名称</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="dbConnection" type="xs:string" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation>数据库连接字符串</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="dbName" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>数据库名称</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="dbType" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>数据库类型</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="MongoDB"/>
|
||||
<xs:enumeration value="SQL"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Scenes types -->
|
||||
<xs:complexType name="scenesType">
|
||||
<xs:sequence>
|
||||
<xs:element name="scene" type="sceneType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="sceneType">
|
||||
<xs:attribute name="id" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>场景ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="processConfigId" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>进程配置ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="worldConfigId" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>世界配置ID</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="sceneRuntimeMode" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>场景运行模式</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="MainThread"/>
|
||||
<xs:enumeration value="MultiThread"/>
|
||||
<xs:enumeration value="ThreadPool"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="sceneTypeString" type="xs:string" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>场景类型字符串</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="networkProtocol" use="optional">
|
||||
<xs:annotation>
|
||||
<xs:documentation>网络协议类型</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="TCP"/>
|
||||
<xs:enumeration value="KCP"/>
|
||||
<xs:enumeration value="WebSocket"/>
|
||||
<xs:enumeration value="HTTP"/>
|
||||
<xs:enumeration value=""/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="outerPort" type="xs:unsignedInt" use="optional" default="0">
|
||||
<xs:annotation>
|
||||
<xs:documentation>外网端口</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="innerPort" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>内网端口</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="sceneType" type="xs:unsignedInt" use="required">
|
||||
<xs:annotation>
|
||||
<xs:documentation>场景类型数值</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Network Runtime type -->
|
||||
<xs:complexType name="networkRuntimeType">
|
||||
<xs:attribute name="inner" use="optional" default="TCP">
|
||||
<xs:annotation>
|
||||
<xs:documentation>服务器内部网络协议</xs:documentation>
|
||||
</xs:annotation>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="TCP"/>
|
||||
<xs:enumeration value="KCP"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="maxMessageSize" type="xs:int" use="optional" default="1048560">
|
||||
<xs:annotation>
|
||||
<xs:documentation>消息体最大长度(字节),默认1048560字节(约1.02MB)</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<!-- Session Runtime type -->
|
||||
<xs:complexType name="sessionRuntimeType">
|
||||
<xs:attribute name="idleTimeout" type="xs:int" use="optional" default="8000">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Session idle check timeout (in milliseconds)</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="idleInterval" type="xs:int" use="optional" default="5000">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Session idle check interval (in milliseconds)</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
</xs:schema>
|
||||
@@ -29,6 +29,9 @@
|
||||
<None Update="NLog.xsd">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Fantasy.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,8 +4,8 @@ using Fantasy.Helper;
|
||||
using Fantasy.IdFactory;
|
||||
using Fantasy.Platform.Net;
|
||||
|
||||
// 设置配置表的路径
|
||||
ConfigTableHelper.Initialize("../../../Config/Binary");
|
||||
|
||||
|
||||
// 设置ID生成规则
|
||||
IdFactoryHelper.Initialize(IdFactoryType.World);
|
||||
// 获取配置文件
|
||||
@@ -21,6 +21,10 @@ ProcessConfigData.Initialize(processConfigText);
|
||||
WorldConfigData.Initialize(worldConfigText);
|
||||
SceneConfigData.Initialize(sceneConfigText);
|
||||
|
||||
//解析配置文件
|
||||
var gameConfigText = await FileHelper.GetTextByRelativePath("../../../Config/Json/configs.Json");
|
||||
ConfigTableHelper.Initialize(gameConfigText,NB.AssemblyHelper.Assemblies);
|
||||
|
||||
// 注册日志模块到框架
|
||||
// 开发者可以自己注册日志系统到框架,只要实现Fantasy.ILog接口就可以。
|
||||
// 这里用的是NLog日志系统注册到框架中。
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"profiles": {
|
||||
"Main": {
|
||||
"commandName": "Project",
|
||||
// "workingDirectory": "$(OutputPath)",
|
||||
"workingDirectory": "$(OutputPath)",
|
||||
"environmentVariables": {},
|
||||
"commandLineArgs": "--m Develop"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user