4.xから5.0へのアップグレードガイド
このガイドでは、v4からv5への移行について、v5.0 RC1と同等以上のバージョンを対象としています(v5 BETAは対象外)。
主な変更点の概要
v4からv5への移行、またはアップデートは問題なく容易におこなえます。 これまでライセンスを保有せず、20CCUの無料ブートストラップライセンスでPhoton Serverを使用してきた場合には、Photon Serverの新しいバージョンを使用できるようにするためにライセンスの取得が必要です。 それ以外に、いくつかの設定変更を確認する必要があります。
ライセンスのアップデートとアップグレード
Photon SDKの新しい主要なバージョンにアップグレードする場合、または新たに購入したライセンスファイルで古いSDKバージョンを使用する場合には、本番環境への移行前に十分な時間を確保し、利用中のPhoton SDKがそのライセンスで作動するか確認してください。
この確認をもっとも簡単におこなうには、利用する予定のPhoton SDKフォルダに該当のライセンスファイルを格納し、Photon ControlアプリケーションからPhotonを起動します。 その後、トレイアプリに表示されたライセンス情報を確認し、またライセンスエラーのログも併せて確認してください。
コードの変更
ここでは、一般的に使用されている型を拡張したカスタムクラスに必要な変更の可能性について説明します。
ApplicationBase
ApplicationBase
クラスを拡張している場合:
IConfiguration
パラメータを受け取るコンストラクタを実装する必要があります。 これを行うためには、NuGet パッケージの "Microsoft.Extensions.Configuration.Abstractions" をインポートする必要があります。(任意) オーバーライドする新しいメソッド:
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への変更
- サーバー・アプリケーション・インスタンスの定義には、新しい構文を使用することをお勧めします。 次の代わりに:
<Configuration> <LoadBalancing> </LoadBalancing> </Configuration>
次を行います:
<Configuration> <Instance Name="LoadBalancing"> </Instance> </Configuration>
- アプリケーションノードの廃止された属性を削除:
- RestartDelayMilliseconds
- WatchFiles
ExcludeFiles
アプリケーションノードの廃止された属性を削除(少なくとも
false
に設定します):- EnableShadowCopy
- EnableAutoRestart
ForceAutoRestart
TCPListenerの廃止された属性を削除:
- MaxQueuedBuffers
MaxPendingWrites
LoadBalancingインスタンスからCounterPublisherアプリケーションノードを削除。
MMOインスタンスを削除。
"UnhandledExceptionPolicy"の値 "ReloadDomain "を "Ignore"または "TerminateProcess"に置き換えました。
LoadBalancingインスタンスでは、デフォルトのアプリケーションがNameServerになり、v4で使用されていたMasterではなくなりました。
### HTTPリスナー
WebSocketListeners(およびその他のHTTPリスナー)の構文が変更されました。
以前(v4):
<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):
<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 version="1.0"?>
<configuration>
<configSections>
<!-- sections defined here -->
</configSections>
<applicationSettings>
<!-- app settings -->
</applicationSettings>
<!-- other settings -->
<Photon>
<CounterPublisher>
</CounterPublisher>
</Photon>
<startup>
</startup>
</configuration>
新しいファイル構造:
<?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
) を除くすべての要素に適用され、変更はありません。
旧設定ノードのフォーマットです。
<setting name="SettingName" serializeAs="String">
<value>SettingValue</value>
</setting>
新しい設定ノード形式:
<SettingName>SettingValue</SettingName>
ファイルごとの変更点をより詳しくご紹介します:
Master
<CustomAuth>
(以前の<AuthSettings>
)は、MasterServer の設定の一部ではなく、NameServer("deploy˶NameServer˶.xml.config")で行われます。
古いファイル構造:
<?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 version="1.0" encoding="utf-8" ?>
<configuration>
<Photon>
<LoadBalancing>
</LoadBalancing>
<Authentication>
</Authentication>
<Master>
</Master>
<WebRpc>
</WebRpc>
<SocketServer>
<S2S>
</S2S>
</SocketServer>
</Photon>
</configuration>
GameServer
古いファイル構造:
<?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 version="1.0" encoding="utf-8" ?>
<configuration>
<Photon>
<LoadBalancing>
</LoadBalancing>
<Authentication>
</Authentication>
<GameServer>
</GameServer>
<WebRpc>
</WebRpc>
<SocketServer>
<S2S>
</S2S>
</SocketServer>
</Photon>
</configuration>
プラグイン
以下のように、<Configuration></Configuration>
を囲むラッパー要素を追加します:
<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
EventCacheEventsCountLimit
: Config Default: 10000.EventCacheSlicesCountLimit
: Config Default: 1000.ActorEventCacheEventsCountLimit
: Config Default: 10000.MaxPropertiesSizePerGameOnGS
: Config Default: 51000.ConnectRetryInterval
はConnectReytryInterval
を置き換えます。Config Default: 15
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 "が用意されています。
コントローラーの設定変更
従来のコントローラ設定:
<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>
新しいコントローラ設定:
<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 version="1.0" encoding="utf-8" ?>
<FeedbackControlSystem>
<FeedbackControllers>
<!-- one or more controllers setup -->
</FeedbackControllers>
</FeedbackControlSystem>
新しい構造 (ラッパー <Configuration></Configuration>
要素/ノードの追加):
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<FeedbackControlSystem>
<FeedbackControllers>
<!-- one or more controllers setup -->
</FeedbackControllers>
</FeedbackControlSystem>
</Configuration>
ロードバランサーの設定変更
LoadBalancerの設定ファイルは deploy\LoadBalancer.configです。
<?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>
新しい構造 (ラッパー <Configuration></Configuration>
要素/ノードの追加):
<?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>