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アドレスを取得します。これは認証設定に影響します。 Photon Serverの実行には有効なライセンスが必要です。 CounterPublisher (App、Project、DLL)は廃止され、SDKから削除されました。 その他、レビューすべき設定変更があります。

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

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

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

コードの変更

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

ApplicationBase

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

  • IConfigurationパラメータを受け取るコンストラクタを実装する必要があります。 コンストラクタの1つが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()
        {
    
  • (任意) オーバーライドする新しいメソッド:

    • 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) は削除されvoid OnDeserializationError(byte[] data, RtsMessageType msgType, string debugMessage, short errorCode = -12, byte code = 0, Exception exception = null)で置換されました。
  • OnDisconnected の最初のパラメータは DisconnectReason または intに変更されました: 変更前: void OnDisconnect(DisconnectReason reasonCode, string reasonDetail) 変更後: void OnDisconnect(int reasonCode, string reasonDetail)
  • (任意) オーバーライドする新しいメソッド:
    • 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インスタンスを削除します。

    廃止された設定

    v5で削除された設定がいくつかあります。新たに導入されたスキーマ検証のため、これらの設定が残っているとサーバーの起動に失敗します。

    アプリケーション

    • 共有ディレクトリのロジックは古く、使用されていません。 関連する設定を削除してください:
      • SharedDirIsExeDir

    アプリケーション

    • 共有ディレクトリのロジックは古く、使用されていません。 関連する設定を削除してください:

      • SharedDirIsExeDir
      • SharedDirectory
    • 変更時のアプリケーションの自動再起動が無効になりました。

      関連する設定を削除してください:

      • RestartDelayMilliseconds
      • WatchFiles
      • ExcludeFiles
      • EnableShadowCopy
      • EnableAutoRestart
      • ForceAutoRestart
    • Resolver

    • EnableOutboundENet

    TCPリスナー

    • 証明書のセットアップが変更されました。詳細は こちらを 参照してください。 古い証明書のセットアップ設定はなくなりました:
      • StoreName
      • UseMachineStore
      • CertificateName
    • DisconnectTimeout
    • MaxQueuedBuffers
    • MaxPendingWrites
    • FlowControlNotificationStepSize
    • PolicyApplication

HTTPリスナー

インスタンス

  • AttachConsole
  • TCPUsePageAllocator
  • UseStandardAllocator
  • UseLockFreeAllocator
  • UseTLSAllocator
  • ENETUseLowContentionBufferAllocator
  • ENETNumAllocators
  • ENETUsePageAllocator
  • ValidateCRCifPresent

IOPool / ENetIOPool / ENetThreadPool

"プライオリティ" 設定はすべての3つのプールから削除されました。

ランタイム

  • OptimiseBroadcastを削除
  • UnhandledExceptionPolicy: 値 "ReloadDomain" を "Ignore" または "TerminateProcess"で置換します。 "ReloadDomain" はサポートされなくなりました。

HTTP WebSocketリスナー

WebSocketListenersの構文が変更されました。

変更前 (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

証明書をセットアップするには、新しい設定に置換してください。 詳細は証明書のセットアップを参照してください。

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

ファイル名の変更

まず、最も注目すべき違いは、各サーバーアプリケーションが、以下のような名前のフォーマットを持つ独自の設定ファイルを持つようになったことです: "{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>
      <S2S>
      </S2S>
      <GS>
      </GS>
      <Limits>
        <Inbound>
        </Inbound>
        <Lobby>
        </Lobby>
      </Limits>
    </Master>
    <WebRpc>
      <HttpQueueSetting>
      </HttpQueueSettings>
    </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>
      <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>

プラグイン

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

XML

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

HttpQueueSettings

HttpQueueはすべてのHTTP (アウトバウンド)に使用されます。 そのため、キューの関連設定を1つのグループにまとめるのは理にかなっています。 このグループの設定はGameServer、WebRPC、CustomAuthの設定(サブグループとして)で使用されます。 ほとんどの設定はv4ですでに利用可能でしたが、より整理され(新しい構造)、クリーンで一貫性のある(ネーミング)ものになりました。

  • HttpRequestTimeout: キューがHTTPレスポンスを待てる時間 (ミリ秒単位) 。
  • LimitHttpResponseMaxSize: HTTPレスポンスのペイロードの最大サイズ。
  • MaxBackoffTime: HTTPリクエストの送信を再試行する際のバックオフのしきい値。
  • MaxConcurrentRequests: 同時HTTPリクエストの最大許容数。
  • MaxErrorRequests: キューに入れられたリクエストの処理中に発生する可能性のあるエラーの最大数。 到達した場合、HttpQueueは切断され(キューに入れられたリクエストをすべてクリアし着信を拒否します)、ReconnectIntervalの後に再開されます。
  • MaxQueuedRequests: キューに入れられるリクエストの最大数。
  • MaxTimedOutRequests: 処理されるのを待つ間にキューでタイムアウトするリクエストの最大数。 If reached the HttpQueue will disconnect (clear all queued requests and reject incoming) and then resume after ReconnectInterval. 到達した場合、HttpQueueは切断され(キューに入れられたリクエストをすべてクリアし着信を拒否します)、ReconnectIntervalの後に再開されます。
  • QueueTimeout: リクエストがHttpQueueにQueueTimeoutミリ秒留まった場合、そのリクエストは自動的に削除されます。
  • ReconnectInterval: HTTPリクエストの処理が再開するまでにキューが待たなければならない時間(ミリ秒単位)。

同じ名前または類似する名前を持つ設定はGameServer、WebRPCまたはCustomAuthノードから削除するか、または<HttpQueueSettings>要素の下に移動する必要があります。

NameServer (新)

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> 要素/ノードを追加):

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