Photon——Setup and Config 设置与配置

 

Setup and Config 设置与配置

 
     This chapter explains how files and folders are organized for the Photon Server and how things are setup. Everything needed is in the deploy folder.
     这章解释了在服务器上文件和文件夹是如何被组织和配置的。
 

     Content 内容

     Organization of Server and Applications 组织服务器与应用程序

 
     There are four versions of Photon in the folders: “bin_Win32”, “bin_x64”, “bin_Win32_xp” and “bin_win64_xp”. We refer to these as binaries-folders.
     在文件夹中这有不同版本的Photon:“bin_Win32”, “bin_x64”, “bin_Win32_xp” and “bin_win64_xp”,我选择需要使用的那个二进制文件夹。
 
     Photon requires a separate folder next to the binaries-folder per application (e.g. “Lite” in the deploy folder). The assemblies must be in a “bin” subfolder (e.g. Lite/bin).
     Photon需要独立的文件夹去存放应用程序,程序集必须放在文件夹内的Bin目录下。
 
Photon Server Screenshot: Folder structure
 
     The following folders in the Server SDK deploy folder are applications: Lite, LiteLobby, MMO, CounterPublisher, Policy Applications are setup in Photon’s config file, as explained below.
     在服务器SDk deploy 文件夹下的应用程序有: Lite, LiteLobby, MMO, CounterPublisher, Policy Applications,被配置在Photon的配置文件中。
     The bin_tools folder currently contains useful tools:
     bin_tools文件夹中有以下可用的工具:
  • Baretail: Our favorite log viewer in the free edition. It is used by PhotonControl to view the latest logs.
          日志查看器
  • Photon Dashboard: The service to collect and concentrate Dashboard Counters and display them on a webpage.
          仪表板计数器
  • Perfmon: Contains a list of PerfMon counters used when you setup counter logging to a file. This is explained under “Administration”.
          性能监视器
  • Stardust: A commandline testclient that can be used to get some load on a machine. This is shown in Photon in 5 Minutes
          命令行测试客户端,可以用来测试机器的负载

     Configuration: PhotonServer.config 配置PhotonServer.config

 
     The main configuration file for Photon is the PhotonServer.config. An identical copy is located in each binaries-folder in the SDK. It is used to setup applications, listeners for IPs and performance specific values. It does not contain config values for the game logic.
     PhotonServer.config是Photon的主配置文件,在每个二进制文件夹中,它是用来配置应用程序,监听器和性能值。他不能用来配置游戏逻辑的值。
 
     The default values make sure Photon scales nicely on more cores but does not overwhelm a regular machine. In general performance tweaks are not needed.
     这默认值保证了Photon的兼容性,一般情况下性能不需要调整
 
     The following settings are most commonly used. More options are described in the “photon-configuration.pdf”, located in the Server SDK.
     以下是最常用的设置项,更多的设置请参看“photon-configuration.pdf”,在本地服务器的SDK中。

     The Application Node 应用程序节点

     The config file defines which applications Photon should load on startup. In the “Applications” node, several “Application” entries can be added.
     配置文件定义了Photon将运行哪些应用程序,在 “Applications” 节点中为每个应用程序添加一个 “Application”节点。
 
 
<Applications Default="Lite">
<!-- Lite Application -->
<Application
Name="Lite"
BaseDirectory="Lite\Lite"
Assembly="Lite"
Type="Lite.LiteApplication"
EnableAutoRestart="true"
WatchFiles="dll;config"
ExcludeFiles="log4net.config">
</Application>
</Applications>
 
     Each application is assigned a name by which the clients reference it on connect (compare: Photon Client Workflow ).
     每个应用的名字是作为客户端连接的依据。
 
     The BaseDirectory defines the folder in which an application resides. It does not name the “\bin” folder but expects it by convention. The Assembly names the .dll of an application and “Type its “main” class (which derives from Photon.SocketServer.Application).
     BaseDirectory 定义了应用程序所在的文件夹,不能命名为 “\bin”,但是要包含它。Assembly 是程序集的名称,Type 是主类的名称(继承于Photon.SocketServer.Application
 
     The setting EnableAutoRestart tells Photon to start a shadow copy of the loaded application. This allows developers to replace the files without locking issues, making development more convenient. Photon will automatically start a new instance of an application 10 seconds after files are changed. WatchFiles and ExcludeFiles refines the list of files that trigger a restart. Clients that connected to a previous shadow copy will stay in it. New connects will use the new logic.
     设置EnableAutoRestart 可以让Photon加载应用的副本。这将允许开发人员在替换文件时不用担心文件被锁住的问题,使的开发更加的方便。Photon将在文件更改后10秒重新启动一个新的应用实例。WatchFiles 和 ExcludeFiles 在触发重启时改进文件列表,连接之前副本的客户将继续使用旧副本,新的连接将创建新的游戏逻辑。
 
     To load multiple applications, simply add more application nodes (with unique name). One of them can be made the default application by using its name (“Lite” in the example). The default app is the fallback for clients that try to connect to an unknown application.
     加载多个应用程序,只需加入新的application 节点(名字必须是唯一的)。可以通过应用名称来设置应用程序为默认应用。当客户端尝试连接一个未知的应用时将连接到默认应用程序。
 
     Applications that are not setup in the PhotonServer.config won’t be loaded and don’t need to be deployed. When an application is in the config but the files are missing Photon won’t start and name the issue in the logs.
     当 PhotonServer.config中的某个应用程序文件丢失时,该应用程序将不被加载和部署,Photon服务将不会启动,该问题将记录在日志中。

     UDPListeners and TCPListeners Nodes  UDP监听和TCP监听节点

 
     These configure UDP and TCP endpoints on your machine respectively. You can use either (e.g. only UDP) or both.
     在你的机器上配置UDP和TCP的端口,你可以使用其中的一种或两种。
 
     The default IP 0.0.0.0 makes Phonton listen on any locally available IP. By replacing the wildcard IP, Photon will open only specific IPs and ports. Multiple UDPListener and TCPListener nodes can be defined, opening several IP/port combinations.
     默认IP是0.0.0.0,这使得Photon将监听所有的本地可用的IP。通过替换IP通配符,Photon将打开指定的IP和端口。可以定义多个UDPListener 和 TCPListener 节点来打开多组IP与端口组合。
 
     Per UDPListener and TCPListener node, you can setup an OverrideApplication or DefaultApplication. Override means: any client that connects to this port will end up in the application named, no matter what the client connects to. Default is a fallback, in case the application named by a client is not found.
     每个UDPListener 和 TCPListener 节点,你可以设置一个OverrideApplication 或 DefaultApplication。Override 的意义是:任意连接该端口的客户端无论它连接到什么都将在已命名的应用中结束,Default 是备用的,用在客户端找不到已命名的应用程序。
 
 
<UDPListeners>
<UDPListener
IPAddress="0.0.0.0"
Port="5055"
OverrideApplication="Master">
</UDPListener>
<UDPListener
IPAddress="0.0.0.0"
Port="5056"
OverrideApplication="Game1">
</UDPListener>
</UDPListeners>
     
     Note: If you are using a license that's bound to an IP you need to set this IP in the config.
     注:如果你是使用一个绑定了IP地址的许可证,你需要将这个IP地址配置到配置文件中。

     TCPSilverlightListeners and TCPFlashListeners Nodes  TCP的Silverlight和Flash的监听节点

 
     Could be removed but are needed when you create Silverlight or Flash games respectively. Both client-side plugins require a server to respond with a “policy file” (unless the website is on the same domain as Photon).
     可以移除该配置,单当你需要创建Silverlight 或 Flash 游戏时是需要的,客户端请求服务器响应一个policy文件(除非网站在同一个域内)

     Timeout Settings 超时设置

 
     Two values in the instance node describe how the server times out unresponsive UDP clients: MinimumTimeout and MaximumTimeout.
     有两个节点来描述服务器超时:MinimumTimeout 和 MaximumTimeout
 
 
<Instance1
EnablePerformanceCounters = "true"
DataSendingDelayMilliseconds="50"
AckSendingDelayMilliseconds="50"
MinimumTimeout="5000"
MaximumTimeout="30000”>
 
     A peer connected with UDP has MinimumTimeout milliseconds to respond before it can be disconnected. The actual time until disconnect, is determined dynamically per peer based on the RTT history. Previously good RTTs will disconnect faster.
     在连接断开之前UDP通信有MinimumTimeout 的时间用于响应,断开的实际时间是动态的基于RTT历史的。
 
     TCP connections have a separate InactivityTimeout setting in the nodes TCPListener and TCPPolicyListener (also in the PhotonServer.config). We set those to 5 seconds (5000ms). If no request arrives in this time, the connection will be timed out and closed. Clients will also regularly Ping the server, to avoid this. Clients don’t timeout for TCP.
     TCP连接有一个独立的配置项InactivityTimeout 在TCPListener 和 TCPPolicyListener 节点,我设置为5000ms,如果请求没有在这个时间间隔内到达,连接将会超时并关闭。客户端将定期Ping服务器以避免这样的超时。
 
     Keep in mind that a client independently monitors a connection and might time it out as well. Both sides should have similar timeouts, fitting your game.
     保持客户端独立的监控连接和时间,使双方将有相似的超时,以适应你的游戏
 

     Send Delay and Ack Delay 发送延迟和Ack延迟

 
     The attributes DataSendingDelayMilliseconds and AckSendingDelayMilliseconds represent a tradeoff between performance and minimal response times. This delay directly adds some lag to reduce the bandwidth usage: the wait allows the server to aggregate commands and send them in one package. The send delay is triggered when the server sends anything, the ack delay by incoming reliable data.
     属性DataSendingDelayMilliseconds 和 AckSendingDelayMilliseconds 代表了性能与最小响应时间之间的权衡。这延迟减小了带宽流量的使用:这等待允许服务器识别命令并用一个数据包发送他们。当服务器进行发送时将触发这个发送延迟,ack延迟是通过传入可靠的数据。
 
     As you can see above, the default values are 50ms each. We found this to be a good value but it causes a \~50ms roundtrip time, even if client and server run on the same machine.
     正如你所看到的,这默认值是50ms。我们发现它是一个很好的设置,在50ms内进行一次往返,即使当客户端和服务器在同一台机器上也是如此。
 
     Depending on your game, you should load test with different values. A delay of 0 is a special case that skips usage of timers, so avoid low delays < 10.
     你可以根据你的游戏,加载测试不同的值。0ms是一个特殊值用于跳过延迟,尽量避免延迟小于10ms
posted @ 2013-05-15 13:40  M守护神  阅读(3071)  评论(0编辑  收藏  举报