Unity study notes (5) - Configuring Photon Server

  1. Download Photon Server

Download address: https://www.photonengine.com/zh-cn/sdks#sdkserverserver

Select Download Photon Server SDK

Install

The file after installation is as shown in the figure

  1. Create a new Photon Server project

Create a new project folder

Create [project name]/[bin] under deploy

This folder is used to store files generated by the project

  1. Create project

Open VS2019 and create a project.

The project is [C#] type [Class Library (.NET Framework)]

  1. development projects

  1. Add references, add the five references in the figure below, and change the references to [photon-server-sdk_v5-0-12-24499-rc1\lib].

  1. Modify the class name and initial file name [PSTest]

  1. [PSTest] inherits [ApplicationBase] and generates the following 3 overloaded methods (press ALT+ENTER to quickly generate)

  1. Override the CreatePeer method. CreatePeer needs to return a PeerBase class, so we create a new class [PSPeer], [PSPeer] inherits from [ClientPeer]. And generate the following 2 overloaded methods and constructor.

  1. Build project

Modify the address where the class library generates build dependencies to the address of the new project you just created, and click [Generate] to generate the project.

  1. Configuration items

Open the PhotonServer.config file

Add the following code under the Configuration tag

<PSTest
    MaxMessageSize="512000"
    MaxQueuedDataPerPeer="512000"
    PerPeerMaxReliableDataInTransit="51200"
    PerPeerTransmitRateLimitKBSec="256"
    PerPeerTransmitRatePeriodMilliseconds="200"
    MinimumTimeout="5000"
    MaximumTimeout="30000"
    DisplayName="PSTest"
        >

        <!-- 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="PSTest">
            </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="PSTest"
                >
            </TCPListener>
        </TCPListeners>



        <!-- 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="PSTest">

            <!-- MMO Demo Application -->
            <Application
                Name="PSTest"
                BaseDirectory="PSTest"
                Assembly="PSTest"
                Type="PSTest.PSTest"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config">
            </Application>

        </Applications>
    </PSTest>

Note: Type="PSTest.PSTest" is because the PSTest class is under PSTest in the namespace, so you can find it by writing this.

This will start the Photon Server project

Guess you like

Origin blog.csdn.net/ximi2231/article/details/129557799