Migrating To 3.1
Migrating The Plugin SDK From 3.0 To 3.1
The Quantum Plugin SDK 3.1 has to be used together with the Quantum SDK 3.1, a 3.0 plugin does not work with 3.1 clients. Upgrade the Unity project first, see the Quantum 3.1 Migration Guide.
Running Quantum 3.1 on the Photon Enterprise Cloud servers requires a recent Photon Server. Contact us to upgrade the Enterprise Cloud before releasing clients with Quantum 3.1.
Overview
- Custom plugin projects target
net10.0instead ofnetcoreapp3.1, install the .NET 10 SDK. - The local Photon Server was upgraded to
6.0.19.36800. - The
deploy_winfolder was removed from the Photon Server folder, all server files are located directly insidePhoton.Server. - The plugin publish folder was renamed from
QuantumPlugin3.0toQuantumPlugin3.1. Quantum.Deterministic.dllwas merged intoQuantum.Engine.dll.PhotonHivePlugin.dllandPhoton.Plugins.Common.dllare no longer shipped in theLibfolder, they are referenced fromPhoton.Server/LoadBalancing/Master/bin.- The Quantum library references were moved into
Quantum.Plugin.Shared.csproj.include. - The session context and the session runner are created by a new server session factory (
DeterministicPluginFactory.CreateSessionFactory()) instead of being passed to theDeterministicServerconstructor. - The LUT files (
assets/LUT) are not required anymore,FPMathno longer uses lookup tables. ThePathToLUTFolderplugin setting is ignored.
Folder Layout
| 3.0 | 3.1 |
|---|---|
Photon.Server/deploy_win/bin (PhotonServer.exe, license) |
Photon.Server/bin |
Photon.Server/deploy_win/LoadBalancing/GameServer/bin/plugin.config |
Photon.Server/LoadBalancing/GameServer/bin/plugin.config |
Photon.Server/deploy_win/Plugins/QuantumPlugin3.0/bin |
Photon.Server/Plugins/QuantumPlugin3.1/bin |
Photon.Server/deploy_win/Plugins/QuantumPlugin3.0/bin/assets/db.json |
Photon.Server/Plugins/QuantumPlugin3.1/bin/assets/db.json |
Photon.Server/deploy_win/log |
Photon.Server/log |
Migration Steps
- Stop all running
PhotonServerprocesses. - Back up the plugin SDK folder, at least the custom plugin projects, the license file and
plugin.config. - Download the Quantum Plugin SDK 3.1 zip.
- Delete the
Photon.ServerandLibfolders of the 3.0 plugin SDK. This also removes the old plugin output including its LUT files (bin/assets/LUT), which are not required anymore. - Unzip the 3.1 zip into the plugin SDK folder, keep your custom plugin projects (or copy them over from the backup).Unzipping overwrites the sample projects (
Quantum.Plugin.Custom.*folders) andQuantum.Plugin.Custom.sln. If you modified a sample project in place, restore it from the backup afterwards and migrate it as described below. - Restore the license file into
Photon.Server/bin. - The
Upgrade-Server.ps1script cannot be used for this migration, it only upgrades the Photon Server of an installed Quantum Plugin SDK 3.1, see Upgrading The Photon Server. - The
plugin.configin the plugin SDK root folder is the local plugin configuration. It is copied toPhoton.Server/LoadBalancing/GameServer/binwhen building any of the plugin projects, so edit the root file instead of the copy. Apply local changes of the olddeploy_win/LoadBalancing/GameServer/bin/plugin.configto it and make sure the plugin is namedName="QuantumPlugin3.1". - Migrate the custom plugin projects, see below.
- In Unity run
Tools > Quantum > Export > Plugin SDK - Sync Server Simulation(orSyncon theQuantumDotnetBuildSettingsasset) to rebuildLib/Quantum.Simulation.dllagainst the 3.1 engine and to export the Quantum DB toPhoton.Server/Plugins/QuantumPlugin3.1/bin/assets. - Build the plugin project and start the Photon Server.
Migrating Custom Plugin Projects
Project Files
- Change the target framework from
<TargetFramework>netcoreapp3.1</TargetFramework>to<TargetFrameworks>net10.0</TargetFrameworks>. - Change
<PluginPublishFolder>QuantumPlugin3.0</PluginPublishFolder>toQuantumPlugin3.1. - Remove the references to
Quantum.Deterministic,Quantum.Engine,Quantum.Log,Quantum.Deterministic.Plugin,Quantum.Deterministic.Server,Quantum.Deterministic.Server.Interface,PhotonHivePluginandPhoton.Plugins.Common, they are now added byQuantum.Plugin.Shared.csproj.include. Only project specific references likeQuantum.JsonandQuantum.Simulationremain in the project. - In
Properties/launchSettings.jsonremovedeploy_winfrom the executable path and the working directory:JSON
"executablePath": "$(ProjectDir)/../Photon.Server/bin/PhotonServer.exe", "workingDirectory": "$(ProjectDir)/../Photon.Server/bin"
Plugin Factory
The CreateDeterministicPlugin() overload with the IPluginLogger parameter is obsolete and no longer virtual, override the overload without logger. Log through Quantum.Log instead of the Photon IPluginLogger.
C#
// 3.0
public override DeterministicPlugin CreateDeterministicPlugin(IPluginHost gameHost, String pluginName, Dictionary<String, String> config, IPluginLogger logger, ref String errorMsg) {
return new DeterministicPlugin(new DeterministicServer());
}
// 3.1
public override DeterministicPlugin CreateDeterministicPlugin(IPluginHost gameHost, String pluginName, Dictionary<String, String> config, ref String errorMsg) {
return new DeterministicPlugin(new DeterministicServer());
}
Session Context And Server Simulation
The DeterministicServer constructors that take a session context or a session runner are obsolete (compile error). Plugins that use the session context (e.g. to access SessionContext.CommandSerializer) or run the server simulation override DeterministicPluginFactory.CreateSessionFactory() and return a ServerSessionFactory. The asset database is then loaded once per plugin factory instead of once per room.
DotNetSessionContext and DotNetSessionRunner were replaced by ServerSessionContext and ServerSessionRunner (located in Assets/Photon/Quantum/Simulation/Server of the Unity project and compiled into Quantum.Simulation.dll).
C#
// 3.0
public override DeterministicPlugin CreateDeterministicPlugin(IPluginHost gameHost, String pluginName, Dictionary<String, String> config, IPluginLogger logger, ref String errorMsg) {
var sessionContext = new DotNetSessionContext { AssetSerializer = new QuantumJsonSerializer() };
var sessionRunner = new DotNetSessionRunner { AssetSerializer = new QuantumJsonSerializer() };
return new DeterministicPlugin(new DeterministicServer(sessionContext, sessionRunner));
}
// 3.1
public override IDeterministicSessionFactory CreateSessionFactory() =>
new ServerSessionFactory(
assetSerializer: new QuantumJsonSerializer(),
runServerSimulation: true); // false to only create the session context
public override DeterministicPlugin CreateDeterministicPlugin(IPluginHost gameHost, String pluginName, Dictionary<String, String> config, ref String errorMsg) =>
new DeterministicPlugin(new QuantumCustomServer());
Subscribe to simulation events and callbacks when the session starts. DeterministicServer.SessionRunner is null when the server simulation is disabled (dashboard, ServerSimulationPercent or a failed start).
C#
public class QuantumCustomServer : DeterministicServer {
public override void OnDeterministicStartSession() {
if (SessionRunner is ServerSessionRunner sessionRunner) {
sessionRunner.CallbackDispatcher.Subscribe<CallbackGameStarted>(this, c => Log.Info("Game Started"));
sessionRunner.EventDispatcher.Subscribe<EventFoo>(this, OnEventFoo);
}
}
}
DeterministicServer API
DeterministicServer.Setup(IHost, IEventSender, IWebhookHost, Dictionary<string, string>)is no longer virtual, overrideSetup(IHost, IEventSender, IWebhookHost, Dictionary<string, string>, object sessionFactory)instead and passsessionFactoryto the base method.DeterministicServer.PluginLocationis now static.
Commands
Clients send their commands in a DeterministicCommandWrapper, which can hold multiple commands per frame (see the AddCommand() API change in the Quantum SDK 3.1).
- Overriding
OnDeterministicCommand(DeterministicPluginClient client, Protocol.Command cmd)and decoding the data as a singleDeterministicCommandno longer works. Decode aDeterministicCommandWrapperand iterate itsCommandsinstead. - Or override the new
OnDeterministicCommand(DeterministicPluginClient client, DeterministicCommand command), which is called for each deserialized command and returnsAccept,DiscardorModified. - Use
SendDeterministicCommand(DeterministicCommand command)to send commands from the server.
C#
public override OnDeterministicCommandResult OnDeterministicCommand(DeterministicPluginClient client, DeterministicCommand command) {
if (command is MyCommand myCmd) {
myCmd.Foo = 42;
return OnDeterministicCommandResult.Modified;
}
return OnDeterministicCommandResult.Accept;
}
Other Changes
- Logs from the Quantum plugin are emitted through
Quantum.Logand prefixed withQuantum:, the PhotonIPluginLoggeris deprecated. - Fixed
ServerSimulationPercentenabling the server simulation for the inverse percentage of rooms. Projects that configured a value below100run the server simulation for a different share of rooms after upgrading. - New dashboard configuration values:
InputFlushMode(Default,Never,Last,Always) to configure the message flush behaviour of the input sent to clients.DeterministicPlugincan also change it at runtime.ForceSnapshotsForAllJoinersto make all subsequent clients use snapshots even when arriving early.SnapshotUploadTimeoutInSec,SnapshotDownloadTimeoutInSecandSnapshotCacheDurationInSecto configure buddy snapshot timings.
DeterministicPlugin.UpdateRateMsoverrides the server update rate per room.- The game result webhook includes
ActorNrandAuthCookieof the clients, and a game result response callback was added. - The
LeaveGameRequestwebhook has the new propertyFailedOnCreate.
Last updated on
Back to top