This document is about: SERVER 5
SWITCH TO

4.xから5.0へのアップグレードガイド

このガイドでは、v4からv5への移行について、v5.0 RC1と同等以上のバージョンを対象としています(v5 BETAは対象外)。

主な変更点の概要

Photon Cloud上にあるので、v5はName Serverを実行します。 クライアントはこれを接続して認証しMaster Serverアドレスを取得します。これは認証設定に影響します。 これまでライセンスをお持ちでなければ(20CCUの無料モードを使用されていた場合)、新しいサーバーバージョンを使用するにはライセンスが必要になります。 CounterPublisher (App、Project、DLL)は廃止され、SDKから削除されました。 その他、レビューすべき設定変更があります。

ライセンスのアップデートとアップグレード

Photon SDKの新しい主要なバージョンにアップグレードする場合、または新たに購入したライセンスファイルで古いSDKバージョンを使用する場合には、本番環境への移行前に十分な時間を確保し、利用中のPhoton SDKがそのライセンスで作動するか確認してください。

この確認をもっとも簡単におこなうには、利用する予定のPhoton SDKフォルダに該当のライセンスファイルを格納し、Photon ControlアプリケーションからPhotonを起動します。 その後、トレイアプリに表示されたライセンス情報を確認し、またライセンスエラーのログも併せて確認してください。

コードの変更

ここでは、一般的に使用されている型を拡張したカスタムクラスに必要な変更の可能性について説明します。

ApplicationBase

ApplicationBaseクラスを拡張している場合:

  • IConfigurationパラメータを受け取るコンストラクタを実装する必要があります。 これを行うためには、NuGet パッケージの "Microsoft.Extensions.Configuration.Abstractions" をインポートする必要があります。 それから設定を(XMLまたはJSONまたはその他から)読み込んでベースのクラスのコンストラクタに受け渡します。 MasterApplicationクラスまたは GameApplicationクラスまたはPhotonApp クラスでの使用方法をご確認ください。 当社が良く使用するパターンは以下の通りです:

    C#

    using Photon.SocketServer;
    using Microsoft.Extensions.Configuration;
    
    public class CustomPhotonApplication : ApplicationBase
    {
        public CustomPhotonApplication() : base(LoadConfiguration())
        {
        }
    
        private static IConfiguration LoadConfiguration()
        {
    
  • (optional) New methods to override:

    • object DecryptAuthToken(InitRequest initRequest, byte[] authToken, int offset, int length, out Dictionary<byte, object> encryptionData, out string errorMsg)
    • void OnWebRTCChannelDestroyed(IPhotonWebRTCPeer peer, object userData, byte channelId)

ClientPeer

ClientPeerクラスを拡張している場合:

  • void OnUnexpectedDataReceived(byte[] data, string debugMessage) is gone and is replaced with void OnDeserializationError(byte[] data, RtsMessageType msgType, string debugMessage, short errorCode = -12, byte code = 0, Exception exception = null)
  • First parameter of OnDisconnected has changed from DisconnectReason or int: before: void OnDisconnect(DisconnectReason reasonCode, string reasonDetail) after: void OnDisconnect(int reasonCode, string reasonDetail)
  • (optional) New methods to override:
    • string GetHistograms()
    • void OnEncryptionQueueOverload(EncryptionQueueFailureParams failureParams)

S2SPeerBase

ClientPeerを拡張したときと同じですが、新たにオーバーライドするオプションのメソッドとして、void OnDisconnectMessage(DisconnectMessage message)が追加されました。

InboundS2SPeer

S2SPeerBaseを拡張したときと同じです。

OutboundS2SPeer

S2SPeerBaseを拡張したときと同じですが、void OnConnectionEstablished(InitV3Response initResponse)をオーバーライドする新しい追加のオプションメソッドが加わりました。

PhotonServer.configへの変更

  • サーバー・アプリケーション・インスタンスの定義には、新しい構文を使用することをお勧めします。 次の代わりに:

    XML

    <Configuration>
      <LoadBalancing>
      </LoadBalancing>
    </Configuration>
    

    次を行います:

    XML

    <Configuration>
      <Instance Name="LoadBalancing">
      </Instance>
    </Configuration>
    
    • LoadBalancingインスタンスでは、デフォルトアプリケーションはNameServerとなりました。V4と異なり、Masterではなくなりました。

    • CounterPublisherアプリケーションノードをLoadBalancingインスタンスから削除します。

    • MMOインスタンスを削除します。

    Obsolete Settings

    There are some settings removed in v5 and due to the newly introduced schema validation, the server will fail to start if these are still present.

    Applications

    • Shared Directory logic is old and not used. Remove related setting:
      • SharedDirIsExeDir

    Application

    • Shared Directory logic is old and not used. Remove related settings:
      • SharedDirIsExeDir
      • SharedDirectory
    • Automatic restarting of applications on change is now disabled. Remove related settings:
      • RestartDelayMilliseconds
      • WatchFiles
      • ExcludeFiles
      • EnableShadowCopy
      • EnableAutoRestart
      • ForceAutoRestart
    • Resolver
    • EnableOutboundENet

    TCPListener

    • Certificate setup has changed read more here. Old certificate setup settings are gone:
      • StoreName
      • UseMachineStore
      • CertificateName
    • DisconnectTimeout
    • MaxQueuedBuffers
    • MaxPendingWrites
    • FlowControlNotificationStepSize
    • PolicyApplication

    HTTPリスナー

    • Access-Control-Allow-Origin

    以前(v4):

XML

    <WebSocketListeners>
      <WebSocketListener
        IPAddress="0.0.0.0"
        Port="9090"
        DisableNagle="true"
        InactivityTimeout="10000"
        OverrideApplication="Master">
      </WebSocketListener>
      <WebSocketListener
        IPAddress="0.0.0.0"
        Port="9091"
        DisableNagle="true"
        InactivityTimeout="10000"
        OverrideApplication="Game">
      </WebSocketListener>
    </WebSocketListeners>

今(v5):

XML

    <HTTPListeners>
      <HTTPListener
        Name="*:[PORT]::Master"
        IPAddress="0.0.0.0"
        Port="9090"
        DisableNagle="true"
        InactivityTimeout="10000">
        <Routing>
          <Route
            Url="/+"
            OverrideApplication="Master"
            PeerType="WebSocket"
            Counters="false" />
          <Route Url="/photon/m" Ping="true" Counters="false"/>
        </Routing>
      </HTTPListener>
      <HTTPListener
        Name="*:[PORT]::Game"
        IPAddress="0.0.0.0"
        Port="9091"
        DisableNagle="true"
        InactivityTimeout="10000"
        AppDataInactivityTimeout="15000">
        <Routing>
          <Route
            Url="/+"
            OverrideApplication="Game"
            PingEvery="2000"
            PeerType="WebSocket"
            Counters="false" />
          <Route Url="/photon/g" Ping="true" Counters="false"/>
        </Routing>
      </HTTPListener>
      <HTTPListener
        Name="*:[PORT]::NameServer"
        IPAddress="0.0.0.0"
        Port="9093"
        DisableNagle="true"
        InactivityTimeout="10000"
        AppDataInactivityTimeout="15000">
        <Routing>
          <Route
            Url="/+"
            OverrideApplication="NameServer"
            PeerType="WebSocket"
            Counters="false" />
          <Route Url="/photon/n" Ping="true" Counters="false"/>
        </Routing>
      </HTTPListener>
    </HTTPListeners>

セキュアなリスナーのセットアップ

Secure Channel (SChannel)からOpenSSLに移行したため、セキュアなリスナーへの証明書のフォーマットや設定が変更されました。

  • WebSocketSecureリスナーの以前の属性を削除します:
    • StoreName
    • UseMachineStore
    • CertificateName

証明書をセットアップするには、新しい設定に置換してください。 新しい設定はTCPListenersに記載されています。また、これらの設定は同じ方法でTCPListenerを拡張するその他のリスナーでも使用されます。

ロードバランシング設定の変更

ファイル名の変更

まず、最も注目すべき違いは、各サーバーアプリケーションが、以下のような名前のフォーマットを持つ独自の設定ファイルを持つようになったことです。"{application_name}.xml.config"です。 これは特にMasterとGameServerのアプリケーションにとって重要で、以前はデフォルトで "Photon.LoadBalancing.dll.config "という同じファイル名と内容を共有していました。 このファイルの内容が2つのファイルに分割されました。

  • "deploy\LoadBalancing\Master\bin\Master.xml.config"
  • "deploy\LoadBalancing\GameServer\bin\GameServer.xml.config"

設定ファイルの一覧を紹介します。

Master

変更前 (v4):

"deploy\Loadbalancing\Master\bin\Photon.LoadBalancing.dll.config"

変更後 (v5):

"deploy\LoadBalancing\Master\bin\Master.xml.config"

GameServer

変更前 (v4):

"deploy\Loadbalancing\GameServer\bin\Photon.LoadBalancing.dll.config"

変更後 (v5):

"deploy\LoadBalancing\GameServer\bin\GameServer.xml.config"

プラグイン

Game Server Pluginsの設定はGameSeverの設定ファイルではなく、"deploy\LoadBalancing\GameServer\bin\plugin.config"というファイルで行われます。 v4では"deploy\LoadBalancing\GameServer\bin\Photon.LoadBalancing.dll.config"に含まれていたので、そこからプラグインの設定を移す必要があります。

変更前 (v4):

"deploy\Loadbalancing\GameServer\bin\Photon.LoadBalancing.dll.config"

変更後 (v5):

"deploy\LoadBalancing\GameServer\bin\plugin.config"

構造変化

2つ目の重要な変更点は、設定ファイルの構造が新しくなったことです。

古いファイル構造:

XML

<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- sections defined here -->
  </configSections>
  <applicationSettings>
     <!-- app settings -->
  </applicationSettings>
  <!-- other settings -->
  <Photon>
    <CounterPublisher>
    </CounterPublisher>
  </Photon>
  <startup>
  </startup>
</configuration>

新しいファイル構造:

XML

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <Photon>
    <!-- all settings here -->
  </Photon>
</configuration>

ルートの <Photon> 要素に注目してください。

古い設定セクション(XML要素)のいくつかは必要なくなりました。

  • <configSections>
  • <applicationSettings>
  • <startup>
  • <CounterPublisher>

一部の要素は名称が変更されています。

  • <Photon.LoadBalancing.Common.CommonSettings><LoadBalacing>になりました。
  • <Photon.Common.Authentication.Settings><Authentication>になりました。
  • <Photon.LoadBalancing.MasterServer.MasterServerSettings><Master>になりました。
  • <Photon.LoadBalancing.GameServer.GameServerSettings><GameServer>になりました。
  • <WebRpcSettings><WebRpc>になりました。
  • <AuthSettings><CustomAuth>になりました。

また、各設定ノードは、従来の一般的な形式ではなく、設定にマッチしたカスタムの名前を持つようになりました。 これは <WebRPC> (以前の <WebRpcSettings>) と <CustomAuth> (以前の <AuthSettings) を除くすべての要素に適用され、変更はありません。

旧設定ノードのフォーマットです。

XML

<setting name="SettingName" serializeAs="String">
    <value>SettingValue</value>
</setting>

新しい設定ノード形式:

XML

<SettingName>SettingValue</SettingName>

ファイルごとの変更点をより詳しくご紹介します:

Master

<CustomAuth>(以前の<AuthSettings>)は、MasterServer の設定の一部ではなく、NameServer("deploy˶NameServer˶.xml.config")で行われます。

古いファイル構造:

XML

<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- sections defined here -->
  </configSections>
  <applicationSettings>
    <Photon.LoadBalancing.Common.CommonSettings>
    </Photon.LoadBalancing.Common.CommonSettings>
    <Photon.Common.Authentication.Settings>
    </Photon.Common.Authentication.Settings>
    <Photon.LoadBalancing.MasterServer.MasterServerSettings>
    </Photon.LoadBalancing.MasterServer.MasterServerSettings>
  </applicationSettings>
  <Photon>
    <CounterPublisher>
    </CounterPublisher>
  </Photon>
  <WebRpcSettings>
  </WebRpcSettings>
  <startup>
  </startup>
</configuration>

新しいファイル構造:

XML

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <Photon>
    <LoadBalancing>
    </LoadBalancing>
    <Authentication>
    </Authentication>
    <Master>
    </Master>
    <WebRpc>
    </WebRpc>
    <SocketServer>
      <S2S>
      </S2S>
    </SocketServer>
  </Photon>
</configuration>

GameServer

古いファイル構造:

XML

<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- sections defined here -->
  </configSections>
  <applicationSettings>
    <Photon.LoadBalancing.Common.CommonSettings>
    </Photon.LoadBalancing.Common.CommonSettings>
    <Photon.Common.Authentication.Settings>
    </Photon.Common.Authentication.Settings>
    <Photon.LoadBalancing.MasterServer.GameServerSettings>
    </Photon.LoadBalancing.MasterServer.GameServerSettings>
  </applicationSettings>
  <Photon>
    <CounterPublisher>
    </CounterPublisher>
  </Photon>
  <WebRpcSettings>
  </WebRpcSettings>
  <startup>
  </startup>
</configuration>

新しいファイル構造:

XML

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <Photon>
    <LoadBalancing>
    </LoadBalancing>
    <Authentication>
    </Authentication>
    <GameServer>
    </GameServer>
    <WebRpc>
    </WebRpc>
    <SocketServer>
      <S2S>
      </S2S>
    </SocketServer>
  </Photon>
</configuration>

プラグイン

以下のように、<Configuration></Configuration>を囲むラッパー要素を追加します:

XML

<Configuration>
  <PluginSettings Enabled="True">
    <Plugins>
      <!-- custom plugin settings here -->
    </Plugins>
  </PluginSettings>
</Configuration>

新しい設定

LoadBalancing

  • GCLatencyMode: Config Default: Interactive.
  • UsePrediction: Config Default: True.

Master

  • UseLegacyLobbies: Config Default: False.
  • LimitGameList: Config Default: 500.
  • LimitGameListUpdate: Config Default :500.
  • LimitSqlFilterResults: Config Default: 100.
  • OnlyLogQueryDataErrors: Config Default: False.
  • WrongWordsForQueryData: Config Default: ALTER;CREATE;DELETE;DROP;EXEC;EXECUTE;INSERT;INSERT INTO;MERGE;SELECT;UPDATE;UNION;UNION ALL.
  • MaxPropertiesSizePerGameOnMS: Config Default: 51000.

GameServer

Old file structure:

XML

<?xml version="1.0"?>
<configuration>
  <configSections>
    <!-- sections defined here -->
  </configSections>
  <applicationSettings>
    <Photon.LoadBalancing.Common.CommonSettings>
    </Photon.LoadBalancing.Common.CommonSettings>
    <Photon.Common.Authentication.Settings>
    </Photon.Common.Authentication.Settings>
    <Photon.LoadBalancing.MasterServer.GameServerSettings>
    </Photon.LoadBalancing.MasterServer.GameServerSettings>
  </applicationSettings>
  <Photon>
    <CounterPublisher>
    </CounterPublisher>
  </Photon>
  <WebRpcSettings>
  </WebRpcSettings>
  <startup>
  </startup>
</configuration>

New file structure:

XML

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <Photon>
    <LoadBalancing>
    </LoadBalancing>
    <Authentication>
    </Authentication>
    <GameServer>
      <S2S>
      </S2S>
      <Master>
      </Master>
      <Limits>
        <Inbound>
          <EventCache>
          </EventCache>
          <Properties>
          </Properties>
          <Operations>
          </Operations>
        </Inbound>
      </Limits>
      <HttpQueueSetting>
      </HttpQueueSettings>
    </GameServer>
    <WebRpc>
      <HttpQueueSetting>
      </HttpQueueSettings>
    </WebRpc>
    <SocketServer>
      <S2S>
      </S2S>
    </SocketServer>
  </Photon>
</configuration>

Plugins

Add a <Configuration></Configuration> enclosing wrapper element as follows:

XML

<Configuration>
  <PluginSettings Enabled="True">
    <Plugins>
      <!-- custom plugin settings here -->
    </Plugins>
  </PluginSettings>
</Configuration>

HttpQueueSettings

HttpQueue is used for everything HTTP (outbound). So it made sense to group the queue's related settings into one group. This group of settings is used in GameServer, WebRPC and CustomAuth settings (as a subgroup). Most of the settings were already available in v4 but now it's more organized (new structure), clean and consistent (naming).

  • HttpRequestTimeout: How long (in milliseconds) the queue can wait for a HTTP response.
  • LimitHttpResponseMaxSize: Maximum size of HTTP response payload.
  • MaxBackoffTime: Backoff threshold when retrying to send a HTTP request.
  • MaxConcurrentRequests: Maximum concurrent HTTP requests allowed.
  • MaxErrorRequests: Maximum number of errors that can occur while processing queued requests. If reached the HttpQueue will disconnect (clear all queued requests and reject incoming) and then resume after ReconnectInterval.
  • MaxQueuedRequests: Maximum number of requests that can be queued.
  • MaxTimedOutRequests: Maximum number of requests that timeout in the queue waiting to be processed. If reached the HttpQueue will disconnect (clear all queued requests and reject incoming) and then resume after ReconnectInterval.
  • QueueTimeout: If a request stays in the HttpQueue for QueueTimeout milliseconds it will be removed automatically.
  • ReconnectInterval: How long (in milliseconds) the queue needs to wait before resuming process of HTTP requests.

Settings with same or similar names from GameServer, WebRPC or CustomAuth nodes need to be removed or moved under a <HttpQueueSettings> element.

NameServer (NEW)

v5では、これまでPhoton Cloudでしか利用できなかったNameServerアプリケーションを追加しました。 このアプリケーションの設定は、2つのファイルを使用して行われます。

  • 実際のアプリケーション用に1つのファイルを作成します。カスタム認証はMasterServerではなくNameServerで行われるようになりました。そのため、これまで設定されていたカスタム認証の設定を、MasterServerの設定ファイル(以前は<AuthSettings>というセクション)からNameServerの設定ファイル(<CustomAuth>というセクションに変更)に移動してください。"deploy\NameServer\bin\NameServer.xml.config"です。

  • NameServerに関連づけられるリージョン(MasterServer)のリストを格納するファイル。このファイルはdeploy\NameServer\bin\NameServer.xml.configの NameServerConfig 設定で変更できます。デフォルトは "deploy\Nameserver.json"です。

PhotonServer.configのLoadBalancingインスタンスのデフォルトアプリケーションが、v4で使用されていた「Master」から「NameServer」に変更されました。

ロードバランサーとワークロードの設定変更

レベル名の更新

v4では5つのレベルしか存在しませんでした。 これらのレベル名は、「Lowest」、「Low」、「Middle」、「High」、「Highest」でした。

現在は、「Level0」、「Level1」、「Level2」、...、「Level9」となっています。 「Lowest」は「Level0」に置き換えられます。 Highest」は「Level9」に置き換えられます。

ワークロード構成の変更

GameServerの設定「WorkloadConfigFile」は、LoadBalancerの設定ファイルのパスを設定します。 v5ではデフォルトで「deploy\Workload.1Gbps.config」となっています(以前は「Workload.config」)。 また、SDKにもサンプルファイル"Workload.config "が用意されています。

コントローラーの設定変更

従来のコントローラ設定:

XML

<add Name="{ControllerName}" InitialInput="0" InitialLevel="Lowest">
  <FeedbackLevels>
    <add Level="Lowest" Value="{LowestValue}"/>
    <add Level="Low" Value="{LowValue}"/>
    <add Level="Normal" Value="{NormalValue}"/>
    <add Level="High" Value="{HighValue}"/>
    <add Level="Highest" Value="{HighestValue}"/>
  </FeedbackLevels>
</add>

新しいコントローラ設定:

XML

<Controller Name="{ContollerName}" InitialInput="0" InitialLevel="Lowest">
  <FeedbackLevels>
    <Level name="0" Level="Level0" Value="{Value0}" ValueDown="{ValueDown0}"/>
    <Level name="1" Level="Level1" Value="{Value1}" ValueDown="{ValueDown1}"/>
    <Level name="2" Level="Level2" Value="{Value2}" ValueDown="{ValueDown2}"/>
    <Level name="3" Level="Level3" Value="{Value3}" ValueDown="{ValueDown3}"/>
    <Level name="4" Level="Level4" Value="{Value4}" ValueDown="{ValueDown4}"/>
    <Level name="5" Level="Level5" Value="{Value5}" ValueDown="{ValueDown5}"/>
    <Level name="6" Level="Level6" Value="{Value6}" ValueDown="{ValueDown6}"/>
    <Level name="7" Level="Level7" Value="{Value7}" ValueDown="{ValueDown7}"/>
    <Level name="8" Level="Level8" Value="{Value8}" ValueDown="{ValueDown8}"/>
    <Level name="9" Level="Level9" Value="{Value9}" ValueDown="{ValueDown9}"/>
  </FeedbackLevels>
</Controller>

ファイル構造の更新

古い構造:

XML

<?xml version="1.0" encoding="utf-8" ?>
<FeedbackControlSystem>
  <FeedbackControllers>
      <!-- one or more controllers setup -->
  </FeedbackControllers>
</FeedbackControlSystem>

新しい構造 (ラッパー <Configuration></Configuration> 要素/ノードの追加):

XML

<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
  <FeedbackControlSystem>
    <FeedbackControllers>
      <!-- one or more controllers setup -->
    </FeedbackControllers>
  </FeedbackControlSystem>
</Configuration>

ロードバランサーの設定変更

LoadBalancerの設定ファイルは deploy\LoadBalancer.configです。

XML

<?xml version="1.0" encoding="utf-8" ?>
<LoadBalancer>
  <LoadBalancerWeights>
    <add Level="Lowest" Value="{LowestValue}"/>
    <add Level="Low" Value="{LowValue}"/>
    <add Level="Normal" Value="{NormalValue}"/>
    <add Level="High" Value="{HighValue}"/>
    <add Level="Highest" Value="{HighestValue}"/>
  </LoadBalancerWeights>
</LoadBalancer>

新構造 (wrapper <Configuration></Configuration> element/node added):

XML

<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
  <LoadBalancer ReserveRatio="{ReserveRatio}" ValueUp="{ValueUp}">
    <LoadBalancerWeights>
      <Level name="0" Level="Level0" Value="{Value0}" />
      <Level name="1" Level="Level1" Value="{Value1}"/>
      <Level name="2" Level="Level2" Value="{Value2}"/>
      <Level name="3" Level="Level3" Value="{Value3}"/>
      <Level name="4" Level="Level4" Value="{Value4}"/>
      <Level name="5" Level="Level5" Value="{Value5}"/>
      <Level name="6" Level="Level6" Value="{Value6}"/>
      <Level name="7" Level="Level7" Value="{Value7}"/>
      <Level name="8" Level="Level8" Value="{Value8}"/>
      <Level name="9" Level="Level9" Value="{Value9}"/>
    </LoadBalancerWeights>
  </LoadBalancer>
</Configuration>
Back to top