Photon Tutorial - Create a simple Photon server (b)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/ultramansail/article/details/102756441

Photon create a simple server (b)

Previous Bowen (Photon Tutorial - Create a simple Photon server (a)) Address: https://blog.csdn.net/ultramansail/article/details/102755901

Create a library file

First, build the solution

  1. Specify the output directory to solve the program generated

(1) Right-click the solution, click on the "Properties"

(2) After the Properties window opens, click "Generate", click on the Browse button after the output path, select the output path, keep in mind that this path, this path after speaking directly with the "output path" statements

2. Click on the "Generate -> Build Solution"

 

3. We found that the "output path /netstandard2.0" catalog many of these documents (some versions may directly in the "output path" directory)

Create an application directory in Photon

First, the new application directory

1. Create in "deploy" directory in the root directory of a Photon folder named "GameServer", under "GameServer" New Folder directory "bin"

2. The document of "output path /netstandard2.0" (or "output path") directory to copy all "the Photon root / deploy / GameServer / bin" directory

Second, the configuration file PhotonServer.config

1. Locate the "PhotonServer.config" file in the "Photon root directory / deploy / bin_Win64" directory, open it

2. At the very end of </ Configuration> at the contents before appending

 

 <!-- Instance settings -->

  <GameServer

MaxMessageSize="512000"

MaxQueuedDataPerPeer="512000"

PerPeerMaxReliableDataInTransit="51200"

PerPeerTransmitRateLimitKBSec="256"

PerPeerTransmitRatePeriodMilliseconds="200"

MinimumTimeout="5000"

MaximumTimeout="30000"

DisplayName="Game Server"

>



    <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->

    <!-- Port 5055 is Photon's default for UDP connections. -->

    <UDPListeners>

      <UDPListener

IPAddress="0.0.0.0"

Port="5055"

OverrideApplication="GameServer">

      </UDPListener>

    </UDPListeners>



    <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->

    <!-- Port 4530 is Photon's default for TCP connecttions. -->

    <!-- A Policy application is defined in case that policy requests are sent to this listener (known bug of some some flash clients) -->

    <TCPListeners>

      <TCPListener

IPAddress="0.0.0.0"

Port="4530"

PolicyFile="Policy\assets\socket-policy.xml"

InactivityTimeout="10000"

OverrideApplication="GameServer"

>

      </TCPListener>

    </TCPListeners>



    <!-- Policy request listener for Unity and Flash (port 843) and Silverlight (port 943)  -->

    <PolicyFileListeners>

      <!-- multiple Listeners allowed for different ports -->

      <PolicyFileListener

IPAddress="0.0.0.0"

Port="843"

PolicyFile="Policy\assets\socket-policy.xml"

InactivityTimeout="10000">

      </PolicyFileListener>

      <PolicyFileListener

IPAddress="0.0.0.0"

Port="943"

PolicyFile="Policy\assets\socket-policy-silverlight.xml"

InactivityTimeout="10000">

      </PolicyFileListener>

    </PolicyFileListeners>



    <!-- WebSocket (and Flash-Fallback) compatible listener -->

    <WebSocketListeners>

      <WebSocketListener

IPAddress="0.0.0.0"

Port="9090"

DisableNagle="true"

InactivityTimeout="10000"

OverrideApplication="GameServer">

      </WebSocketListener>

    </WebSocketListeners>



    <!-- Defines the Photon Runtime Assembly to use. -->

    <Runtime

Assembly="PhotonHostRuntime, Culture=neutral"

Type="PhotonHostRuntime.PhotonDomainManager"

UnhandledExceptionPolicy="Ignore">

    </Runtime>





    <!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. -->

    <!-- Application-folders must be located in the same folder as the bin_win32 folders. The BaseDirectory must include a "bin" folder. -->

    <Applications Default="GameServer">



      <!-- Game Server Application -->

      <Application

Name="GameServer"

BaseDirectory="GameServer"

Assembly="GameServer"

Type="GameServer.GameServer"

ForceAutoRestart="true"

WatchFiles="dll;config"

ExcludeFiles="log4net.config">

      </Application>



      <!-- CounterPublisher Application -->

      <Application

Name="CounterPublisher"

BaseDirectory="CounterPublisher"

Assembly="CounterPublisher"

Type="Photon.CounterPublisher.Application"

ForceAutoRestart="true"

WatchFiles="dll;config"

ExcludeFiles="log4net.config">

      </Application>



    </Applications>

  </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

Guess you like

Origin blog.csdn.net/ultramansail/article/details/102756441