当前位置:   article > 正文

Photon教程——建立简单的Photon服务器(二)_photon 中 overrideapplication

photon 中 overrideapplication

建立简单的Photon服务器(二)

上一篇博文(Photon教程——建立简单的Photon服务器(一))的地址:https://blog.csdn.net/ultramansail/article/details/102755901

生成库文件

一、生成解决方案

  1. 指定解决方案生成的输出目录

(1)右击解决方案,点击“属性”

(2)属性窗口打开后,点击“生成”,点击输出路径后的浏览按钮,选择输出路径,要记住这个路径,以后讲这个路径直接用“输出路径”表述

2.点击“生成->生成解决方案”

 

3.我们发现“输出路径/netstandard2.0”目录多了这些文件(有些版本可能直接在“输出路径”目录)

在Photon目录创建应用

一、新建应用目录

1.在Photon根目录下的“deploy”目录下新建一个文件夹,命名为“GameServer”,在“GameServer”目录下新建文件夹“bin”

2.把“输出路径/netstandard2.0”(或“输出路径”)目录下的文件全部拷贝到“Photon根目录/deploy/GameServer/bin”目录

二、配置PhotonServer.config文件

1.在“Photon根目录/deploy/bin_Win64”目录下找到“PhotonServer.config”文件,打开它

2.在最末尾的</Configuration>前追加一下内容

 

  1.  <!-- Instance settings -->
  2.   <GameServer
  3. MaxMessageSize="512000"
  4. MaxQueuedDataPerPeer="512000"
  5. PerPeerMaxReliableDataInTransit="51200"
  6. PerPeerTransmitRateLimitKBSec="256"
  7. PerPeerTransmitRatePeriodMilliseconds="200"
  8. MinimumTimeout="5000"
  9. MaximumTimeout="30000"
  10. DisplayName="Game Server"
  11. >
  12.     <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
  13.     <!-- Port 5055 is Photon's default for UDP connections. -->
  14.     <UDPListeners>
  15.       <UDPListener
  16. IPAddress="0.0.0.0"
  17. Port="5055"
  18. OverrideApplication="GameServer">
  19.       </UDPListener>
  20.     </UDPListeners>
  21.     <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
  22.     <!-- Port 4530 is Photon's default for TCP connecttions. -->
  23.     <!-- A Policy application is defined in case that policy requests are sent to this listener (known bug of some some flash clients) -->
  24.     <TCPListeners>
  25.       <TCPListener
  26. IPAddress="0.0.0.0"
  27. Port="4530"
  28. PolicyFile="Policy\assets\socket-policy.xml"
  29. InactivityTimeout="10000"
  30. OverrideApplication="GameServer"
  31. >
  32.       </TCPListener>
  33.     </TCPListeners>
  34.     <!-- Policy request listener for Unity and Flash (port 843) and Silverlight (port 943)  -->
  35.     <PolicyFileListeners>
  36.       <!-- multiple Listeners allowed for different ports -->
  37.       <PolicyFileListener
  38. IPAddress="0.0.0.0"
  39. Port="843"
  40. PolicyFile="Policy\assets\socket-policy.xml"
  41. InactivityTimeout="10000">
  42.       </PolicyFileListener>
  43.       <PolicyFileListener
  44. IPAddress="0.0.0.0"
  45. Port="943"
  46. PolicyFile="Policy\assets\socket-policy-silverlight.xml"
  47. InactivityTimeout="10000">
  48.       </PolicyFileListener>
  49.     </PolicyFileListeners>
  50.     <!-- WebSocket (and Flash-Fallback) compatible listener -->
  51.     <WebSocketListeners>
  52.       <WebSocketListener
  53. IPAddress="0.0.0.0"
  54. Port="9090"
  55. DisableNagle="true"
  56. InactivityTimeout="10000"
  57. OverrideApplication="GameServer">
  58.       </WebSocketListener>
  59.     </WebSocketListeners>
  60.     <!-- Defines the Photon Runtime Assembly to use. -->
  61.     <Runtime
  62. Assembly="PhotonHostRuntime, Culture=neutral"
  63. Type="PhotonHostRuntime.PhotonDomainManager"
  64. UnhandledExceptionPolicy="Ignore">
  65.     </Runtime>
  66.     <!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. -->
  67.     <!-- Application-folders must be located in the same folder as the bin_win32 folders. The BaseDirectory must include a "bin" folder. -->
  68.     <Applications Default="GameServer">
  69.       <!-- Game Server Application -->
  70.       <Application
  71. Name="GameServer"
  72. BaseDirectory="GameServer"
  73. Assembly="GameServer"
  74. Type="GameServer.GameServer"
  75. ForceAutoRestart="true"
  76. WatchFiles="dll;config"
  77. ExcludeFiles="log4net.config">
  78.       </Application>
  79.       <!-- CounterPublisher Application -->
  80.       <Application
  81. Name="CounterPublisher"
  82. BaseDirectory="CounterPublisher"
  83. Assembly="CounterPublisher"
  84. Type="Photon.CounterPublisher.Application"
  85. ForceAutoRestart="true"
  86. WatchFiles="dll;config"
  87. ExcludeFiles="log4net.config">
  88.       </Application>
  89.     </Applications>
  90.   </GameServer>

注Application代码块中,Name是服务的名称(应用的名称),BaseDirectory是应用相对于“Photon根目录/deploy”的路径,Assembly是程序集,是主类(继承自ApplicationBase的类)的名称,Type是类的类型,一般为“命名空间.类名”

三、开启服务器

1.打开主程序“Phton根目录/deploy/bin_Win64/PhotonControl.exe”

2.右击PhotonControl的后台图标,点击“Game Instance->Start as application”,启动服务(如果服务启动不了,请检查配置文件),退出应用则点击“Stop application”

下一篇博文(Photon教程——使用log4net插件在Photon中打印log)的地址:https://blog.csdn.net/ultramansail/article/details/102756662

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/82159
推荐阅读
相关标签
  

闽ICP备14008679号