/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <IZoneAuthenticationService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncZoneAuthenticationServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ZoneAuthentication"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }) .SingleInstance(); builder.Register <IZoneRegistryService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncEndpointZoneRegistryService(QueryForRemoteServiceEndpoint(serviceDiscovery, "ZoneManager"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }) //.As<IZoneRegistryServiceQueueable>() .As <IZoneRegistryService>() .SingleInstance(); }
public AuthorizedServiceDiscoveryServiceResolver(IServiceDiscoveryService discoveryClient, TServiceEnumType serviceType, IReadonlyAuthTokenRepository tokenRepository) : base(discoveryClient, serviceType) { TokenRepository = tokenRepository ?? throw new ArgumentNullException(nameof(tokenRepository)); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { base.Load(builder); ContainerBuilder register = builder; register.Register(context => { //The below is not true for right now, we have global service discovery point to the gameserver for testing. //This registeration is abit complicated //because we are skipping the game server selection //to do this we must query the service discovery and THEN //we query the the gameserver's service discovery. IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointCharacterService(QueryForRemoteServiceEndpoint(serviceDiscovery, "GameServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new FiddlerEnabledWebProxyHandler() })); }) .As <ICharacterService>() .SingleInstance(); //Name query service //TODO: We should hand;e this differently register.Register(context => new CachedNameQueryServiceDecorator(new RemoteNetworkedNameQueryService(context.Resolve <ICharacterService>()))) .As <INameQueryService>() .SingleInstance(); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <IDownloadableContentServerServiceClient>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncEndpointDownloadableContentService(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }); //IStaticContentDataServiceClient builder.Register <IStaticContentDataServiceClient>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncStaticContentDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <IDownloadableContentServerServiceClient>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncEndpointDownloadableContentService(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }); builder.Register <ICreatureDataServiceClient>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); //IReadonlyAuthTokenRepository tokenRepository = context.Resolve<IReadonlyAuthTokenRepository>(); //return new AsyncCreatureDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) }); return(new AsyncCreatureDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"))); }); builder.Register <IGameObjectDataServiceClient>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); //IReadonlyAuthTokenRepository tokenRepository = context.Resolve<IReadonlyAuthTokenRepository>(); //return new AsyncCreatureDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) }); return(new AsyncGameObjectDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"))); }); builder.Register <IPlayerSpawnPointDataServiceClient>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); //IReadonlyAuthTokenRepository tokenRepository = context.Resolve<IReadonlyAuthTokenRepository>(); //return new AsyncCreatureDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) }); return(new AsyncPlayerSpawnPointDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"))); }); builder.Register <IGameObjectBehaviourDataServiceClient <WorldTeleporterInstanceModel> >(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); //IReadonlyAuthTokenRepository tokenRepository = context.Resolve<IReadonlyAuthTokenRepository>(); //return new AsyncCreatureDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) }); return(new AsyncGameObjectBehaviourDataServiceClient <WorldTeleporterInstanceModel>(CreateBehaviourDataEndpointFromServiceEndpoint(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), "WorldTeleporterData"))); }); builder.Register <IGameObjectBehaviourDataServiceClient <AvatarPedestalInstanceModel> >(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); //IReadonlyAuthTokenRepository tokenRepository = context.Resolve<IReadonlyAuthTokenRepository>(); //return new AsyncCreatureDataServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) }); return(new AsyncGameObjectBehaviourDataServiceClient <AvatarPedestalInstanceModel>(CreateBehaviourDataEndpointFromServiceEndpoint(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"), "AvatarPedestalData"))); }); }
//TODO: Put this in a base class or something protected async Task <string> QueryForRemoteServiceEndpoint(IServiceDiscoveryService serviceDiscovery, string serviceType) { ResolveServiceEndpointResponse endpointResponse = await serviceDiscovery.DiscoverService(new ResolveServiceEndpointRequest(ClientRegionLocale.US, serviceType)); if (!endpointResponse.isSuccessful) { throw new System.InvalidOperationException($"Failed to query for Service: {serviceType} Result: {endpointResponse.ResultCode}"); } //TODO: Do we need extra slash? return($"{endpointResponse.Endpoint.EndpointAddress}:{endpointResponse.Endpoint.EndpointPort}/"); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <INameQueryService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); //TODO: Eventually gameserver won't be endpoint for namequeries. return(new AsyncEndpointNameQueryService(QueryForRemoteServiceEndpoint(serviceDiscovery, "NameQuery"), new RefitSettings() { HttpMessageHandlerFactory = () => new FiddlerEnabledWebProxyHandler() })); }); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <IVivoxAuthorizationService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncVivoxAuthorizationServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, GladMMONetworkConstants.VIVOX_AUTHENTICATION_SERVICE_NAME), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }); }
/// <inheritdoc /> public SocialConnectionGameInitializable( [NotNull] IEnumerable <ISignalRConnectionHubInitializable> initializableSocialServices, [NotNull] IServiceDiscoveryService serviceDiscoveryService, [NotNull] ILocalPlayerDetails playerDetails, [NotNull] IReadonlyAuthTokenRepository authTokenProvider, [NotNull] ILog logger) { InitializableSocialServices = initializableSocialServices ?? throw new ArgumentNullException(nameof(initializableSocialServices)); ServiceDiscoveryService = serviceDiscoveryService ?? throw new ArgumentNullException(nameof(serviceDiscoveryService)); PlayerDetails = playerDetails ?? throw new ArgumentNullException(nameof(playerDetails)); AuthTokenProvider = authTokenProvider ?? throw new ArgumentNullException(nameof(authTokenProvider)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public InitializeRealtimeSocialServiceEventListener(ILocalPlayerSpawnedEventSubscribable subscriptionService, [NotNull] ILog logger, [NotNull] IServiceDiscoveryService serviceDiscoveryService, [NotNull] ILocalPlayerDetails playerDetails, [NotNull] IReadonlyAuthTokenRepository authTokenProvider, [NotNull] IRemoteSocialHubClient remoteSocialClient, [NotNull] IEnumerable <IConnectionHubInitializable> connectionHubInitializable) : base(subscriptionService) { Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ServiceDiscoveryService = serviceDiscoveryService ?? throw new ArgumentNullException(nameof(serviceDiscoveryService)); PlayerDetails = playerDetails ?? throw new ArgumentNullException(nameof(playerDetails)); AuthTokenProvider = authTokenProvider ?? throw new ArgumentNullException(nameof(authTokenProvider)); RemoteSocialClient = remoteSocialClient ?? throw new ArgumentNullException(nameof(remoteSocialClient)); ConnectionHubInitializable = connectionHubInitializable ?? throw new ArgumentNullException(nameof(connectionHubInitializable)); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <IAuthenticationService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointAuthenticationService(QueryForRemoteServiceEndpoint(serviceDiscovery, "Authentication"), new RefitSettings() { HttpMessageHandlerFactory = () => new FiddlerEnabledWebProxyHandler() })); }); //TODO: We should do this only once, so we should move this to it's own special setup scene for one-time stuff. Unity3DProtobufPayloadRegister payloadRegister = new Unity3DProtobufPayloadRegister(); payloadRegister.RegisterDefaults(); payloadRegister.Register(ZoneServerMetadataMarker.ClientPayloadTypesByOpcode, ZoneServerMetadataMarker.ServerPayloadTypesByOpcode); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { //TODO: Renable one day when Unity3D can support netstandard2.0 c builder.RegisterType <ProxiedAzureServiceBusHttpClientHandler>() .AsSelf(); //This is not dangerous to distribute the SAS. //The reasoning for this is that zones need to be able to push into the queue anyway. //Authorization occurs at the other end so it doesn't matter if people try to do sneaky stuff. string zoneManagerQueueClientAccessKey = @"PABbPWzpF+ZSb8YOyGOUUN9RYgnO56mkAOgasXXqE/I="; //this SAS is only for send. ServiceBusConnectionStringBuilder serviceHubConnectionBuilder = new ServiceBusConnectionStringBuilder($@"Endpoint=sb://projectvindictive.servicebus.windows.net/;SharedAccessKeyName=UserZoneServer;SharedAccessKey={zoneManagerQueueClientAccessKey};EntityPath=zoneservermanagement"); //https://projectvindictive.servicebus.windows.net/zoneservermanagement //Azure Service Bus register IQueueClient zoneManagerServiceQueue = new QueueClient(serviceHubConnectionBuilder); builder.RegisterInstance(zoneManagerServiceQueue) .As <IQueueClient>() .SingleInstance(); //throw new InvalidOperationException($"TODO: Go disable normal REST for {nameof(IZoneRegistryServiceQueueable)}."); builder.Register <IZoneRegistryServiceQueueable>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); ProxiedAzureServiceBusHttpClientHandler handler = context.Resolve <ProxiedAzureServiceBusHttpClientHandler>(); return(new AsyncEndpointZoneRegistryService(QueryForRemoteServiceEndpoint(serviceDiscovery, "ZoneManager"), new RefitSettings() { HttpMessageHandlerFactory = () => handler })); }); builder.Register <IZonePersistenceServiceQueueable>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); ProxiedAzureServiceBusHttpClientHandler handler = context.Resolve <ProxiedAzureServiceBusHttpClientHandler>(); return(new AsyncEndpointZonePersistenceService(QueryForRemoteServiceEndpoint(serviceDiscovery, "ZoneManager"), new RefitSettings() { HttpMessageHandlerFactory = () => handler })); }); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <ISocialService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); IReadonlyAuthTokenRepository tokenRepository = context.Resolve <IReadonlyAuthTokenRepository>(); return(new AsyncSocialServiceClient(QueryForRemoteServiceEndpoint(serviceDiscovery, GladMMONetworkConstants.SOCIAL_SERVICE_NAME), new RefitSettings() { HttpMessageHandlerFactory = () => new AuthenticatedHttpClientHandler(tokenRepository) })); }); builder.RegisterType <DefaultRemoteSocialHubServer>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType <DefaultRemoteSocialHubClient>() .AsImplementedInterfaces() .SingleInstance(); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { builder.Register <IAuthenticationService>(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); if (PrecomputedEndpoint != null) { return(RestService.For <IAuthenticationService>(PrecomputedEndpoint, new RefitSettings() { HttpMessageHandlerFactory = HttpClientHandlerFactory })); } else { return(new AsyncEndpointAuthenticationService(QueryForRemoteServiceEndpoint(serviceDiscovery, "Authentication"), new RefitSettings() { HttpMessageHandlerFactory = HttpClientHandlerFactory })); } }); }
private async Task <string> QueryServiceForEndpoint(string serviceType) { if (string.IsNullOrWhiteSpace(serviceType)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(serviceType)); } await Task.Delay(5000) .ConfigureAwait(false); IServiceDiscoveryService service = ServiceUrlToDiscoveryServiceMap[_ServiceDiscoveryEndpoint]; ResolveServiceEndpointResponseModel response = await service.Discover(new ResolveServiceEndpointRequestModel(Locale, serviceType)) .ConfigureAwait(false); if (!response.isSuccessful) { throw new InvalidOperationException($"Failed to query {nameof(IServiceDiscoveryService)} for the Service: {serviceType} in Locale: {Locale} for Reason: {response.ResultCode}."); } return($"{response.Endpoint.EndpointAddress}:{response.Endpoint.EndpointPort}"); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { //https://stackoverflow.com/questions/4926676/mono-https-webrequest-fails-with-the-authentication-or-decryption-has-failed ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.CheckCertificateRevocationList = false; Unity3DProtobufPayloadRegister payloadRegister = new Unity3DProtobufPayloadRegister(); payloadRegister.RegisterDefaults(); payloadRegister.Register(ZoneServerMetadataMarker.ClientPayloadTypesByOpcode, ZoneServerMetadataMarker.ServerPayloadTypesByOpcode); //Set the sync context UnityExtended.InitializeSyncContext(); //TODO: We need to not have such a high rate of Update and need to add prediction. Application.targetFrameRate = 60; builder.RegisterInstance(new ProtobufNetGladNetSerializerAdapter(PrefixStyle.Fixed32)) .As <INetworkSerializationService>(); builder.RegisterType <ZoneServerDefaultRequestHandler>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterInstance(new UnityLogger(LogLevel.All)) .As <ILog>(); builder.RegisterType <MessageHandlerService <GameClientPacketPayload, GameServerPacketPayload, IPeerSessionMessageContext <GameServerPacketPayload> > >() .As <MessageHandlerService <GameClientPacketPayload, GameServerPacketPayload, IPeerSessionMessageContext <GameServerPacketPayload> > >() .SingleInstance(); builder.RegisterInstance(new DefaultSessionCollection()) .As <IRegisterable <int, ZoneClientSession> >() .As <ISessionCollection>() .SingleInstance(); builder.RegisterInstance(new NetworkAddressInfo(IPAddress.Parse("192.168.0.3"), 5006)) .As <NetworkAddressInfo>() .SingleInstance() .ExternallyOwned(); builder.RegisterType <ZoneServerApplicationBase>() .SingleInstance() .AsSelf(); RegisterEntityMappableCollections(builder); //TODO: We should automate the registeration of message senders builder.RegisterType <VisibilityChangeMessageSender>() .AsImplementedInterfaces() .AsSelf(); builder.RegisterType <DefaultGameObjectToEntityMappable>() .As <IReadonlyGameObjectToEntityMappable>() .As <IGameObjectToEntityMappable>() .SingleInstance(); RegisterPlayerFactoryServices(builder); builder.RegisterType <DefaultEntityFactory <DefaultEntityCreationContext> >() .AsImplementedInterfaces() .AsSelf() .SingleInstance(); builder.RegisterType <GenericMessageSender <PlayerSelfSpawnEventPayload> >() .AsSelf() .AsImplementedInterfaces(); builder.RegisterType <DefaultManagedSessionFactory>() .AsImplementedInterfaces(); //TODO: Extract this into a handlers registrar //This is for mapping connection IDs to the main controlled EntityGuid. builder.RegisterInstance(new ConnectionEntityMap()) .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType <PlayerEntityGuidEnumerable>() .As <IPlayerEntityGuidEnumerable>() .AsSelf(); builder.RegisterType <MovementUpdateMessageSender>() .As <INetworkMessageSender <EntityMovementMessageContext> >() .AsSelf(); //Keep this one here, zoneserver needs it. builder.Register <IServiceDiscoveryService>(context => RestService.For <IServiceDiscoveryService>(@"http://192.168.0.3:5000")); builder.Register(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointZoneServerToGameServerService(QueryForRemoteServiceEndpoint(serviceDiscovery, "GameServer"))); }) .As <IZoneServerToGameServerClient>() .SingleInstance(); builder.RegisterType <DefaultMovementHandlerService>() .As <IMovementDataHandlerService>() .AsSelf(); builder.RegisterType <PathMovementBlockHandler>() .AsImplementedInterfaces() .AsSelf(); builder.RegisterType <PositionChangeMovementBlockHandler>() .AsImplementedInterfaces() .AsSelf(); builder.RegisterType <UtcNowNetworkTimeService>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType <FieldValueUpdateFactory>() .AsSelf() .AsImplementedInterfaces(); RegisterEntityDestructionServices(builder); //Honestly, before running this I think it'll be a MIRACLE if this actually works //Registering the generic networkmessage sender builder.RegisterGeneric(typeof(GenericMessageSender <>)) .As(typeof(INetworkMessageSender <>).MakeGenericType(typeof(GenericSingleTargetMessageContext <>))) .SingleInstance(); RegisterLockingPolicies(builder); //IPhysicsTriggerEventSubscribable TriggerEventSubscribable builder.RegisterInstance(GlobalPhysicsEventSystem.Instance) .AsImplementedInterfaces() .SingleInstance(); }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { base.Load(builder); //https://stackoverflow.com/questions/4926676/mono-https-webrequest-fails-with-the-authentication-or-decryption-has-failed ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.CheckCertificateRevocationList = false; builder.Register(context => { //The below is not true for right now, we have global service discovery point to the gameserver for testing. //This registeration is abit complicated //because we are skipping the game server selection //to do this we must query the service discovery and THEN //we query the the gameserver's service discovery. IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointCharacterService(QueryForRemoteServiceEndpoint(serviceDiscovery, "GameServer"))); }) .As <ICharacterService>() .SingleInstance(); //Name query service builder.Register(context => new CachedNameQueryServiceDecorator(new RemoteNetworkedNameQueryService(context.Resolve <ICharacterService>()))) .As <INameQueryService>() .SingleInstance(); builder.Register(context => { //The below is not true for right now, we have global service discovery point to the gameserver for testing. //This registeration is abit complicated //because we are skipping the game server selection //to do this we must query the service discovery and THEN //we query the the gameserver's service discovery. IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointZoneServerService(QueryForRemoteServiceEndpoint(serviceDiscovery, "GameServer"))); }) .As <IZoneServerService>() .SingleInstance(); builder.Register(context => { //The below is not true for right now, we have global service discovery point to the gameserver for testing. //This registeration is abit complicated //because we are skipping the game server selection //to do this we must query the service discovery and THEN //we query the the gameserver's service discovery. IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointContentServerService(QueryForRemoteServiceEndpoint(serviceDiscovery, "ContentServer"))); }) .As <IContentServerServiceClient>() .SingleInstance(); //Social service /*builder.RegisterType<SignalRForwardedIRemoteSocialTextChatHubClient>() * .AsImplementedInterfaces() * .SingleInstance(); * * builder.RegisterType<SignalRForwardedIRemoteSocialTextChatHubServer>() * .AsImplementedInterfaces() * .SingleInstance();*/ }
/// <inheritdoc /> protected override void Load(ContainerBuilder builder) { //https://stackoverflow.com/questions/4926676/mono-https-webrequest-fails-with-the-authentication-or-decryption-has-failed ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.CheckCertificateRevocationList = false; //TODO: Extract to seperate module like the client. //Register the serialization models. Unity3DProtobufPayloadRegister unityProtobufRegisteration = new Unity3DProtobufPayloadRegister(); unityProtobufRegisteration.RegisterDefaults(); unityProtobufRegisteration.Register(); //Set the sync context UnityAsyncHelper.InitializeSyncContext(); Application.targetFrameRate = 10; QualitySettings.vSyncCount = 0; HandleConfigurableDependencies(builder); //AuthToken //ZoneServerAuthenticationTokenRepository: IReadonlyAuthTokenRepository builder.RegisterType <ZoneServerAuthenticationTokenRepository>() .As <IReadonlyAuthTokenRepository>() .As <IAuthTokenRepository>() .SingleInstance(); builder.RegisterType <ProtobufNetGladNetSerializerAdapter>() .As <INetworkSerializationService>() .SingleInstance(); builder.RegisterType <ZoneServerDefaultRequestHandler>() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterInstance(new UnityLogger(LogLevel.All)) .As <ILog>(); builder.RegisterType <MessageHandlerService <GameClientPacketPayload, GameServerPacketPayload, IPeerSessionMessageContext <GameServerPacketPayload> > >() .As <MessageHandlerService <GameClientPacketPayload, GameServerPacketPayload, IPeerSessionMessageContext <GameServerPacketPayload> > >() .SingleInstance(); builder.RegisterType <ZoneServerApplicationBase>() .SingleInstance() .AsSelf(); RegisterEntityMappableCollections(builder); //TODO: We should automate the registeration of message senders builder.RegisterType <VisibilityChangeMessageSender>() .AsImplementedInterfaces() .AsSelf(); builder.RegisterType <DefaultGameObjectToEntityMappable>() .As <IReadonlyGameObjectToEntityMappable>() .As <IGameObjectToEntityMappable>() .SingleInstance(); RegisterPlayerFactoryServices(builder); builder.RegisterType <GenericMessageSender <PlayerSelfSpawnEventPayload> >() .AsSelf() .AsImplementedInterfaces(); builder.RegisterType <DefaultManagedSessionFactory>() .AsImplementedInterfaces(); //TODO: Extract this into a handlers registrar //This is for mapping connection IDs to the main controlled EntityGuid. builder.RegisterInstance(new ConnectionEntityMap()) .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType <PlayerEntityGuidEnumerable>() .As <IPlayerEntityGuidEnumerable>() .AsSelf(); builder.RegisterType <MovementUpdateMessageSender>() .As <INetworkMessageSender <EntityMovementMessageContext> >() .AsSelf(); //Keep this one here, zoneserver needs it. /*builder.Register<IServiceDiscoveryService>(context => RestService.For<IServiceDiscoveryService>("https://test-guardians-servicediscovery.azurewebsites.net")) * .As<IServiceDiscoveryService>() * .SingleInstance();*/ //builder.Register<IServiceDiscoveryService>(context => RestService.For<IServiceDiscoveryService>(@"http://72.190.177.214:5000")); builder.Register <IServiceDiscoveryService>(context => RestService.For <IServiceDiscoveryService>(@"http://72.190.177.214:5000")) .As <IServiceDiscoveryService>() .SingleInstance(); builder.Register(context => { IServiceDiscoveryService serviceDiscovery = context.Resolve <IServiceDiscoveryService>(); return(new AsyncEndpointZoneServerToGameServerService(QueryForRemoteServiceEndpoint(serviceDiscovery, "GameServer"))); }) .As <IZoneServerToGameServerClient>() .SingleInstance(); /*builder.RegisterType<DefaultMovementHandlerService>() * .As<IMovementDataHandlerService>() * .AsSelf(); * * builder.RegisterType<PathMovementBlockHandler>() * .AsImplementedInterfaces() * .AsSelf(); * * builder.RegisterType<PositionChangeMovementBlockHandler>() * .AsImplementedInterfaces() * .AsSelf();*/ builder.RegisterType <UtcNowNetworkTimeService>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); builder.RegisterType <FieldValueUpdateFactory>() .AsSelf() .AsImplementedInterfaces(); RegisterEntityDestructionServices(builder); //Honestly, before running this I think it'll be a MIRACLE if this actually works //Registering the generic networkmessage sender builder.RegisterGeneric(typeof(GenericMessageSender <>)) .As(typeof(INetworkMessageSender <>).MakeGenericType(typeof(GenericSingleTargetMessageContext <>))) .SingleInstance(); RegisterLockingPolicies(builder); //IPhysicsTriggerEventSubscribable TriggerEventSubscribable builder.RegisterInstance(GlobalPhysicsEventSystem.Instance) .AsImplementedInterfaces() .SingleInstance(); //DefaultEntitySessionMessageSender : IEntitySessionMessageSender builder.RegisterType <DefaultEntitySessionMessageSender>() .As <IEntitySessionMessageSender>(); //EntityBaseStatsDataFactory : IFactoryCreatable<EntityBaseStatsModel, EntityDataStatsDerivable> builder.RegisterType <EntityBaseStatsDataFactory>() .As <IFactoryCreatable <EntityBaseStatsModel, EntityDataStatsDerivable> >(); //RoundRobinSpawnStrategy : ISpawnPointStrategy builder.RegisterType <PlayerRoundRobinSpawnStrategy>() .As <ISpawnPointStrategy>(); builder.RegisterType <PlayerSpawnPointQueue>() .AsSelf() .SingleInstance(); builder.RegisterType <DefaultThreadUnSafeKnownEntitySet>() .AsSelf() .AsImplementedInterfaces() .SingleInstance(); //ServerMovementGeneratorFactory : IFactoryCreatable<IMovementGenerator<GameObject>, EntityAssociatedData<IMovementData>> builder.RegisterType <ServerMovementGeneratorFactory>() .As <IFactoryCreatable <IMovementGenerator <GameObject>, EntityAssociatedData <IMovementData> > >() .As <IMovementGeneratorFactory>() .AsSelf(); builder.RegisterType <RemoteGameObjectDataService>() .As <IGameObjectDataService>() .SingleInstance(); //DefaultSpellDataCollection : ISpellDataCollection, IReadonlySpellDataCollection builder.RegisterType <DefaultSpellDataCollection>() .AsImplementedInterfaces() .SingleInstance(); }