Last active
August 19, 2016 19:20
-
-
Save tenowg/0c76c7db5e93a09e7533f919ae50a8f3 to your computer and use it in GitHub Desktop.
Upgrade to Autofac 4.0.0 for MultiplayGameFramework (more docs can be found at: https://docs.autofac.org/en/latest/configuration/xml.html)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Nuget Packages | |
// Autofac 4.0.0 | |
// Autofac.Configuration v4.0.0 | |
// Microsoft.Extensions.Configuration.Json v1.0.0 | |
// Microsoft.Extensions.Configuration | |
// Microsoft.Extensions.Configuration.FileExtensions | |
// Microsoft.Extensions.Configuration.Abstractions | |
// Need to create a ConfigBuilder from Microsoft.Extensions.Configuration | |
// This code replaces the current Autofac code in PhotonApplication.cs in Setup() | |
var config = new ConfigurationBuilder(); | |
// Add the file, similar to before, but to configBuilder | |
config.AddJsonFile(Path.Combine(BinaryPath, ApplicationName + ".json")); | |
// Build the configuration, this is from Autofac.Configurations.ConfigurationModule | |
var module = new ConfigurationModule(config.Build()); | |
// Create Autofac container | |
var builder = new ContainerBuilder(); | |
builder.RegisterInstance(this).SingleInstance(); | |
builder.RegisterInstance(Log).As<ILogger>().SingleInstance(); | |
// RegisterModule knows how to handle the config that was built | |
builder.RegisterModule(module); | |
// Build as usual | |
var container = builder.Build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"components": [ | |
{ | |
"type": "MultiplayerGameFramework.Implementation.Config.ServerConfiguration, MultiplayerGameFramework", | |
"parameters": { | |
"allowPhysicalClients": true, | |
"parentPort": 4530, | |
"siblingPort": 0, | |
"subCodeParameterCode": 0, | |
"peerIdCode": 1 | |
} | |
} | |
], | |
"modules": [ | |
{ | |
"type": "MGF_Photon.Modules.ProxyServerModule, MGF-Photon" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment