日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Photon——Setup and Config 设置与配置

發布時間:2024/6/14 编程问答 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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?組織服務器與應用程序
    • Configuration: PhotonServer.config?配置PhotonServer.config
    • The Application Node?應用程序節點
    • UDPListeners and TCPListeners Nodes?UDP監聽和TCP監聽節點
    • TCPSilverlightListeners and TCPFlashListeners Nodes?TCP的Silverlight和Flash的監聽節點
    • Timeout Settings?超時設置
    • Send Delay and Ack Delay?發送延遲和Ack延遲

?????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目錄下。 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”節點。
? <ApplicationsDefault="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). 每個應用的名字是作為客戶端連接的依據。 TheBaseDirectorydefines the folder in which an application resides. It does not name the “\bin” folder but expects it by convention. TheAssemblynames the .dll of an application and “Type its “main” class (which derives from?Photon.SocketServer.Application). BaseDirectory?定義了應用程序所在的文件夾,不能命名為?“\bin”,但是要包含它。Assembly?是程序集的名稱,Type是主類的名稱(繼承于Photon.SocketServer.Application) The settingEnableAutoRestarttells 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.WatchFilesandExcludeFilesrefines 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 thePhotonServer.configwon’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:MinimumTimeoutandMaximumTimeout. 有兩個節點來描述服務器超時:MinimumTimeout?和?MaximumTimeout
? <Instance1 EnablePerformanceCounters="true" DataSendingDelayMilliseconds="50" AckSendingDelayMilliseconds="50" MinimumTimeout="5000" MaximumTimeout="30000”> ?
A peer connected with UDP hasMinimumTimeoutmilliseconds 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 separateInactivityTimeoutsetting in the nodesTCPListenerand TCPPolicyListener (also in thePhotonServer.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 attributesDataSendingDelayMillisecondsandAckSendingDelayMillisecondsrepresent 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. Thesenddelay is triggered when the server sends anything, theackdelay 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

轉載于:https://www.cnblogs.com/liusuqi/archive/2013/05/15/3079697.html

總結

以上是生活随笔為你收集整理的Photon——Setup and Config 设置与配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。