PhotonServer官网:https://www.photonengine.com/en/OnPremise
官网的帮助文档:Documentatain
Photon Server是一款实时的Socket服务器和开发框架,快速、使用方便、容易扩展,服务端架构在Windows系统平台上,采用C#语言编写,Photon Server发布包括两个部分,Client SDK Release和Server SDK Update,Server SDK的版本是v2.4.5,而Client SDK的版本是v6.2.0。客户端SDK提供了多种平台的开发API,包括DotNet,Unity3D,C/C++等。SDK就是指可以为第三方开发者提供特定的软件包、软件框架、硬件平台、操作系统等创建应用软件开发工具的集合,并且SDK还能简单的为某个程序设计语言提供应用程序接口API的一些文件。
1.下载Server SDK(On-Premises)
进入官网,点击页面右上角的SDKs,然后在Choose for your project的条件中选中Server,可以看到图标,点击图标后点Download SDK下载exe文件。运行或右键解压服务器端,不要出现中文目录,解压出\ Photon-OnPremise-Server-SDK_v4-0-29-11263。
\deploy:部署服务器应用,放置开发服务器的代码及相关文件(\deploy\bin_Win64\PhotonControl.exe:服务器程序运行文件,证书存放的在\deploy\bin_Win64)
\doc:存放帮助文档
\lib:存放动态链接库(Photon3Unity3D.dll是用来开发基于Unity3D的客户端,好像Photon.SocketServer.dll是用来开发服务器端)
\src-server:Photon Server的源码
2. 配置PhotonServer.config文件
一个Photon instance代表一类配置,一个Photon instance可以包含多个服务器端的应用。打开deploy\bin_Win64\PhotonServer.config
<MMoDemoInstance <!--这块配置内容的名称,即一个Photon instances--> MaxMessageSize="512000" MaxQueuedDataPerPeer="512000" PerPeerMaxReliableDataInTransit="51200" PerPeerTransmitRateLimitKBSec="256" PerPeerTransmitRatePeriodMilliseconds="200" MinimumTimeout="5000" MaximumTimeout="30000" DisplayName="MMO Demo" <!--显示在Photon instances的名称--> > <!-- 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="MMoDemo"> </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="MMoDemo" > </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="MMoDemo"> </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="MMoDemo"> <!-- MMO Demo Application --> <Application Name="MMoDemo"<!--这个应用的名称,上面会用到 --> BaseDirectory="MmoDemo"<!--\deploy下这个服务器应用的文件名称 --> Assembly="Photon.MmoDemo.Server"<!-—程序集名称 --> Type="Photon.MmoDemo.Server.PhotonApplication"<!--主程序名称--> 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> </MMoDemoInstance>
原文地址:https://www.cnblogs.com/DonYao/p/8454956.html