public DemoService( IOptionsSnapshot <DemoSettings> settings, SecretClient secretClient, MsiDbContext dbContext, BlobServiceClient blobServiceClient, DataLakeServiceClient dataLakeServiceClient, EventHubProducerClient eventHubProducerClient, ServiceBusClient serviceBusClient, TokenCredential tokenCredential, CustomApiClient customApiClient, CosmosClient cosmosClient, TextAnalyticsClient textAnalyticsClient, MapsApiClient mapsApiClient, ConfigurationClient configurationClient) { _settings = settings.Value; _secretClient = secretClient; _dbContext = dbContext; _blobServiceClient = blobServiceClient; _dataLakeServiceClient = dataLakeServiceClient; _eventHubProducerClient = eventHubProducerClient; _serviceBusClient = serviceBusClient; _tokenCredential = tokenCredential; _customApiClient = customApiClient; _cosmosClient = cosmosClient; _textAnalyticsClient = textAnalyticsClient; _mapsApiClient = mapsApiClient; _configurationClient = configurationClient; }
public HomeController(IDemoService demoService, IOptionsSnapshot <DemoSettings> demoSettings, ILogger <HomeController> logger, IConfiguration config) { _demoService = demoService; _settings = demoSettings.Value; _logger = logger; _config = config; }
public static float bulletSpeed = 550f; // value is also in servers GlobalVars.cs public static DemoSettings GetDefaultSettings() { DemoSettings result = new DemoSettings(); // photon // result.ServerAddress = "73.118.224.14:5055"; result.ServerAddress = "localhost:5055"; result.UseTcp = false; result.ApplicationName = "MmoDemo"; // grid result.WorldName = "Mmo Grid Demo"; result.TileDimensions = new Vector(1000, 1000); result.GridSize = result.TileDimensions * 20; // 20 tiles. each is TileDimensions of size // game engine result.AutoMoveInterval = 1000; result.SendReliable = false; result.AutoMoveVelocity = 10; result.AutoMove = false; result.maxVel = 10; result.maxVelSq = result.maxVel * result.maxVel; return(result); }
public QueueListenerService( IHubContext <QueueMessageHub, IClientReceiver> messageHub, IOptions <DemoSettings> demoSettings) { _messageHub = messageHub; _settings = demoSettings.Value; }
public DemoService( IOptionsSnapshot <DemoSettings> settings, BookShopDBContext dbContext) { _settings = settings.Value; _dbContext = dbContext; }
public EventHubsListenerService( IHubContext <EventHubMessageHub, IClientReceiver> messageHub, IOptions <DemoSettings> demoSettings) { _messageHub = messageHub; _demoSettings = demoSettings.Value; }
public DemoController( IDemoService demoService, IOptionsSnapshot <DemoSettings> demoSettings, IConfiguration configuration) { _demoService = demoService; _settings = demoSettings.Value; }
static void Main(string[] args) { _settings = Settings.Load<DemoSettings>("settings.js"); string apiUri = _settings.apiUri; int waitInterval = _settings.waitInterval; _settings.waitInterval = 5; _settings.Save(); }
public DemoService( IOptionsSnapshot <DemoSettings> settings, MsiDbContext dbContext, IHttpClientFactory httpClientFactory) { _settings = settings.Value; _dbContext = dbContext; _httpClient = httpClientFactory.CreateClient(HttpClients.CustomApi); }
private void MoveRelative(Vector offset) { Vector newPosition = new Vector(Game.Avatar.Position); DemoSettings settings = (DemoSettings)Game.Settings; newPosition.X += offset.X * settings.AutoMoveVelocity; newPosition.Y += offset.Y * settings.AutoMoveVelocity; MoveAbsolute(newPosition); }
public QueueListenerService( TelemetryClient telemetryClient, IHubContext <QueueMessageHub> messageHub, IOptions <DemoSettings> demoSettings) { _telemetryClient = telemetryClient; _messageHub = messageHub; _settings = demoSettings.Value; }
public CustomApiClient( HttpClient httpClient, IOptionsSnapshot <DemoSettings> settings, TokenCredential tokenCredential) { _httpClient = httpClient; _settings = settings.Value; _tokenCredential = tokenCredential; }
public ManagedIdentityConnectionInterceptor(DemoSettings options) { _tenantId = options.ManagedIdentityTenantId; if (string.IsNullOrEmpty(_tenantId)) { _tenantId = null; } _tokenProvider = new AzureServiceTokenProvider(); }
public void ConfigureContainer(ContainerBuilder builder) { var projectSettings = new CustomVisionProjectSettings { ProjectName = Configuration.GetValue <string>("CustomVision:Project:Name"), ProjectType = Configuration.GetValue <string>("CustomVision:Project:Type") }; var authoringSettings = new CustomVisionAuthoringSettings { AccountRegion = Configuration.GetValue <string>("CustomVision:AuthoringService:AccountRegion"), AccountName = Configuration.GetValue <string>("CustomVision:AuthoringService:AccountName"), AccountKey = Configuration.GetValue <string>("CustomVision:AuthoringService:AccountKey") }; var predictionSettings = new CustomVisionPredictionSettings { AccountRegion = Configuration.GetValue <string>("CustomVision:PredictionService:AccountRegion"), AccountName = Configuration.GetValue <string>("CustomVision:PredictionService:AccountName"), AccountKey = Configuration.GetValue <string>("CustomVision:PredictionService:AccountKey") }; builder.Register(ctx => { var systemSettings = new SystemSettings { WorkingDirectory = Configuration.GetValue <string>("FileSystem:WorkingDirectory") }; return(systemSettings); }).As <ISystemSettings>(); builder.Register(ctx => { var demoSettingsEntries = Configuration.GetSection("Demos").Get <List <DemoSetting> >(); var demoSettings = new DemoSettings { Settings = demoSettingsEntries }; return(demoSettings); }).As <IDemoSettings>(); var customVisionProjectService = new CustomVisionProjectService(projectSettings, authoringSettings); builder.Register(ctx => customVisionProjectService).As <ICustomVisionProjectService>(); builder.Register(ctx => new CustomVisionAuthoringService(customVisionProjectService, authoringSettings)).As <ICustomVisionAuthoringService>(); builder.Register(ctx => new CustomVisionPredictionService(customVisionProjectService, projectSettings, predictionSettings)).As <ICustomVisionPredictionService>(); builder.RegisterType <VideoFrameExtractionService>().As <IVideoFrameExtractionService>(); // TODO: move to module as below // builder.RegisterModule(new MyApplicationModule()); }
public ManagedIdentityConnectionInterceptor(DemoSettings options) { _tenantId = options.ManagedIdentityTenantId; if (string.IsNullOrEmpty(_tenantId)) { _tenantId = null; } _tokenCredential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { SharedTokenCacheTenantId = _tenantId, VisualStudioCodeTenantId = _tenantId, VisualStudioTenantId = _tenantId, }); }
public void Awake() { if (IsDebugLogEnabled) { Debug.Log("Awake"); } DemoSettings settings = DemoSettings.GetDefaultSettings(); this.Game = new Game(this, settings, "unity"); var peer = new PhotonPeer(this.Game, settings.UseTcp ? ConnectionProtocol.Tcp : ConnectionProtocol.Udp) { ChannelCount = 3 }; this.Game.Initialize(peer); }
public void ValidatorForSettings_WhenCalled_SettingsIsPassedThrough() { var builder = new JobbrBuilder(); var demoSettings = new DemoSettings(); object settingsToValidate = null; builder.Add <DemoSettings>(demoSettings); builder.Add <IConfigurationValidator>(new DemoComponentValidator(s => settingsToValidate = s)); var jobbr = builder.Create(); jobbr.Start(); Assert.IsNotNull(settingsToValidate); Assert.AreSame(demoSettings, settingsToValidate); }
public void StartNetworked(int port, string address, string playerSessionId, MonoBehaviour parent, DemoSettingsClient settings) { var spawnPoint = DemoSettings.GetSpawnPoint(); var playerConfig = DemoSettings.GetPlatformCharacterConfig(); var recieveByGuid = new Dictionary <string, MessageHandler>(); networkStream = NetworkApi.OpenOutbound(port, address, parent); networkStream.Recieve.Add((opCode, message) => { if (opCode == OpCode.PLAYER_ACCEPTED) { MessageHandler recieve = null; var acceptMsg = (PlayerAcceptMessage)message; var isSelf = acceptMsg.playerSessionId.Equals(playerSessionId); Debug.Log("client (" + playerSessionId + ")" + " accepts (" + acceptMsg.playerGuid + ") as self? " + isSelf); if (acceptMsg.playerSessionId.Equals(playerSessionId)) { var spawned = GameObject.Instantiate(settings.playerPrefab, spawnPoint, Quaternion.identity); var playerComp = spawned.GetComponent <PlayerCompClient>(); recieve = playerComp.RegisterNetwork(networkStream.Send, playerConfig, acceptMsg.PlayerGuid, acceptMsg.trustDistance); } else { var spawned = GameObject.Instantiate(settings.otherPlayerPrefab, spawnPoint, Quaternion.identity); var playerComp = spawned.GetComponent <OtherPlayerCompClient>(); recieve = playerComp.RegisterNetwork(playerConfig, settings.interpolation); } recieveByGuid[acceptMsg.PlayerGuid] = recieve; } else { MessageHandler reciever = null; var found = recieveByGuid.TryGetValue(PlayerGuidUtil.Get(message), out reciever); if (found) { reciever?.Invoke(opCode, message); } } return(1); }); var joinMessage = new PlayerJoinMessage(); joinMessage.playerSessionId = playerSessionId; networkStream.Send(OpCode.PLAYER_JOIN, joinMessage); }
public static DemoSettings GetDefaultSettings() { DemoSettings result = new DemoSettings(); // photon result.ServerAddress = "localhost:5055"; result.UseTcp = false; result.ApplicationName = "MmoDemo"; // grid result.WorldName = "Mmo Grid Demo"; result.TileDimensions = new Vector(1000, 1000); result.GridSize = result.TileDimensions*20; // 20 tiles. each is TileDimensions of size // game engine result.AutoMoveInterval = 1000; result.SendReliable = false; result.AutoMoveVelocity = 10; result.AutoMove = false; return result; }
public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddSignalR(); services.AddTransient <IDemoService, DemoService>(); services.AddSingleton <IHostedService, QueueListenerService>(); services.AddSingleton <IHostedService, EventHubsListenerService>(); services.Configure <DemoSettings>(Configuration.GetSection("Demo")); DemoSettings demoSettings = Configuration.GetSection("Demo").Get <DemoSettings>(); var managedIdentityInterceptor = new ManagedIdentityConnectionInterceptor(demoSettings); services.AddDbContext <MsiDbContext>(o => o.UseSqlServer(demoSettings.SqlConnectionString).AddInterceptors(managedIdentityInterceptor)); services.AddApplicationInsightsTelemetry(o => { o.EnableQuickPulseMetricStream = true; o.InstrumentationKey = Configuration["ApplicationInsights:InstrumentationKey"]; }); services.AddHttpClient(HttpClients.CustomApi); }
protected void AccessDataSource1_Modifying(object sender, SqlDataSourceCommandEventArgs e) { DemoSettings.AssertNotReadOnly(); }
public async Task <int> StartNetworked(Func <string, bool> acceptPlayer, Action <string, int> handlePlayerExit, MonoBehaviour parent, DemoSettingsServer settings) { this.handlePlayerExit = handlePlayerExit; parent.StartCoroutine(Update()); var spawnPoint = DemoSettings.GetSpawnPoint(); var platformerConfig = DemoSettings.GetPlatformCharacterConfig(); networkStream = await NetworkApi.AcceptInbound(parent, settings.port); networkStream.Recieve.Add((opCode, guid, message) => { if (opCode == OpCode.PLAYER_JOIN) { var joinMessage = (PlayerJoinMessage)message; acceptPlayer(joinMessage.playerSessionId); var onCancel = networkStream.Recieve.GetConnectionCancellation(guid); onCancel.Token.Register(() => { lock (abandonedPlayers){ abandonedPlayers.Enqueue(guid); } }); playerGuids.Add(guid); var serverRep = GameObject.Instantiate(settings.playerPrefab, spawnPoint, Quaternion.identity); var serverRepComp = serverRep.GetComponent <PlayerCompServer>(); var serverRepRecieve = serverRepComp.RegisterNetwork(guid, (toSendCode, toSendMessage) => { playerGuids.ForEach((targetGuid) => { try{ networkStream.Send(toSendCode, targetGuid, toSendMessage); } catch (Exception e) { Debug.Log("failed sending to player: " + e.Message); } }); return(1); }, platformerConfig, settings); ServerRepData repData = new ServerRepData(); repData.comp = serverRepComp; repData.session = joinMessage.playerSessionId; repData.recieve = serverRepRecieve; repData.guid = guid; serverReps[guid] = repData; var acceptMsg = new PlayerAcceptMessage(); acceptMsg.trustDistance = settings.trustDistance; playerGuids.ForEach((existingPlayer) => { acceptMsg.playerGuid = guid; var isSendingToNewlyAccepted = PlayerGuidUtil.IsFor(acceptMsg, existingPlayer); acceptMsg.playerSessionId = isSendingToNewlyAccepted ? joinMessage.playerSessionId : string.Empty; networkStream.Send(OpCode.PLAYER_ACCEPTED, existingPlayer, acceptMsg); if (!isSendingToNewlyAccepted) { acceptMsg.playerSessionId = string.Empty; acceptMsg.playerGuid = existingPlayer; networkStream.Send(OpCode.PLAYER_ACCEPTED, guid, acceptMsg); } }); } else { if (serverReps.ContainsKey(guid)) { serverReps[guid].recieve(opCode, message); } } return(1); }); return(1); }
private void ReadKeyboardInput() { if (Input.GetKey(KeyCode.Keypad5) || Input.GetKey(KeyCode.C)) { if (this.lastKeyPress + 0.3f < Time.time) { Vector newPosition = new Vector(); newPosition.X = Game.WorldData.Width / 2 + Game.WorldData.BoundingBox.Min.X; newPosition.Y = Game.WorldData.Height / 2 + Game.WorldData.BoundingBox.Min.Y; Game.Avatar.MoveAbsolute(newPosition, Game.Avatar.Rotation); this.lastKeyPress = Time.time; } } DemoSettings settings = (DemoSettings)Game.Settings; if (Input.GetKey(KeyCode.M)) { if (this.lastKeyPress + 0.3f < Time.time) { settings.AutoMove = !settings.AutoMove; this.lastKeyPress = Time.time; } } if (Input.GetKey(KeyCode.Keypad8) || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { MoveRelative(Game.MoveUp); } if (Input.GetKey(KeyCode.Keypad4) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { MoveRelative(Game.MoveLeft); } if (Input.GetKey(KeyCode.Keypad2) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) { MoveRelative(Game.MoveDown); } if (Input.GetKey(KeyCode.Keypad6) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { MoveRelative(Game.MoveRight); } if (Input.GetKey(KeyCode.Keypad7)) { MoveRelative(Game.MoveUpLeft); } if (Input.GetKey(KeyCode.Keypad9)) { MoveRelative(Game.MoveUpRight); } if (Input.GetKey(KeyCode.Keypad1)) { MoveRelative(Game.MoveDownLeft); } if (Input.GetKey(KeyCode.Keypad3)) { MoveRelative(Game.MoveDownRight); } // for some reason, a German keyboard's '+' will result in a Equals key. Anywhere else, this should be '+', too. I hope. if (Input.GetKey(KeyCode.RightBracket)) { if (this.lastKeyPress + 0.05f < Time.time) { IncreaseViewDistance(); this.lastKeyPress = Time.time; } } if (Input.GetKey(KeyCode.LeftBracket)) { if (this.lastKeyPress + 0.05f < Time.time) { DecreaseViewDistance(); this.lastKeyPress = Time.time; } } if (Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Slash)) { if (this.lastKeyPress + 0.05f < Time.time) { InterestArea cam; Game.TryGetCamera(0, out cam); cam.ResetViewDistance(); this.lastKeyPress = Time.time; } } }
public SiteSettingsController(ISiteService siteService, IOptionsSnapshot <DemoSettings> demoOptions) { _siteService = siteService; _demoSettings = demoOptions.Value; }
public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddSignalR(); services.AddTransient <IDemoService, DemoService>(); services.AddSingleton <IHostedService, QueueListenerService>(); services.AddSingleton <IHostedService, EventHubsListenerService>(); services.Configure <DemoSettings>(Configuration.GetSection("Demo")); DemoSettings demoSettings = Configuration.GetSection("Demo").Get <DemoSettings>(); var managedIdentityInterceptor = new ManagedIdentityConnectionInterceptor(demoSettings); services.AddDbContext <MsiDbContext>(o => o.UseSqlServer(demoSettings.SqlConnectionString).AddInterceptors(managedIdentityInterceptor)); services.AddApplicationInsightsTelemetry(o => { o.EnableQuickPulseMetricStream = true; o.ConnectionString = Configuration["ApplicationInsights:ConnectionString"]; }); var tenantId = string.IsNullOrEmpty(demoSettings.ManagedIdentityTenantId) ? null : demoSettings.ManagedIdentityTenantId; var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { SharedTokenCacheTenantId = tenantId, VisualStudioCodeTenantId = tenantId, VisualStudioTenantId = tenantId, }); services.AddSingleton <TokenCredential>(credential); TokenCredential customApiCredential = string.IsNullOrEmpty(demoSettings.CustomApiClientSecret) ? credential : new ClientSecretCredential( demoSettings.CustomApiTenantId, demoSettings.CustomApiClientId, demoSettings.CustomApiClientSecret); services.AddHttpClient <CustomApiClient, CustomApiClient>( (httpClient, serviceProvider) => { var settings = serviceProvider.GetRequiredService <IOptionsSnapshot <DemoSettings> >(); return(new CustomApiClient(httpClient, settings, customApiCredential)); }); services.AddHttpClient <MapsApiClient>(); services.AddSingleton((IServiceProvider _) => { return(new CosmosClient(Configuration["Demo:CosmosDbAccountUri"], credential)); }); services.AddAzureClients(clients => { clients.AddBlobServiceClient(new Uri($"https://{demoSettings.StorageAccountName}.blob.core.windows.net")); clients.AddDataLakeServiceClient(new Uri($"https://{demoSettings.DataLakeStoreName}.blob.core.windows.net")); clients.AddEventHubProducerClientWithNamespace($"{demoSettings.EventHubNamespace}.servicebus.windows.net", demoSettings.EventHubName); clients.AddServiceBusClientWithNamespace($"{demoSettings.ServiceBusNamespace}.servicebus.windows.net"); clients.AddSecretClient(new Uri(demoSettings.KeyVaultBaseUrl)); clients.AddTextAnalyticsClient(new Uri(demoSettings.CognitiveServicesBaseUrl)); clients.AddConfigurationClient(new Uri(demoSettings.AppConfigUrl)); clients.UseCredential(credential); }); }
public BunnyDemo() { settings = DemoSettings.GetDefaults(); }
public ConfigurationController(DemoSettings demoSettings) { this.demoSettings = demoSettings; }
protected override void OnLoad(EventArgs e) { PauseSyncButton = new Button(Key.Space); PrevSceneButton = new Button(Key.F3); NextSceneButton = new Button(Key.F4); ReloadDemoButton = new Button(Key.F5); RestartDemoOrRetreatSceneButton = new Button(Key.F6); AdvanceSceneButton = new Button(Key.F7); InputEnabledButton = new Button(Key.F8); CameraModeButton = new Button(Key.F9); CameraSpeedDownButton = new Button(Key.F10); CameraSpeedUpButton = new Button(Key.F11); PrintFrameButton = new Button(Key.F12); tunableManager = TunableManager.GetSingleton(); syncSystem = SyncSystem.GetSingleton(); renderer = Renderer.GetSingleton(); string dataFolder = "data"; AssetManager.WorkingDir = dataFolder; AssetManager assetManager = AssetManager.GetSingleton(); Logger.LogPhase("Asset manager is created"); assetManager.LoadAll(); assetManager.printLoadedAssets(); Logger.LogPhase("Assets have been loaded"); tunableManager.ReloadValues(); Logger.LogPhase("Config file have been loaded"); demoWrapper = new DemoWrapper(); demoWrapper.Create(); demoSettings = demoWrapper.Demo.GetDemoSettings(); // Audio .................................... Logger.LogPhase("Initializing audio system"); if (demoSettings.AudioEngineSetting == DemoSettings.AudioEngine.System) { audioSystem = new SystemAudio(); } if (demoSettings.AudioEngineSetting == DemoSettings.AudioEngine.Dummy) { if (demoSettings.AudioEnabled == true) { Logger.LogError(Logger.ErrorState.User, "Initialized dummy audio when Audio is enabled."); } audioSystem = new DummyAudioSystem(); } bool audioInitOk = audioSystem.Initialize(); if (!audioInitOk) { Logger.LogError(Logger.ErrorState.Critical, "Audio system failed to initialize."); return; } Logger.LogPhase("Audio has been initialized"); demoWrapper.SetAudioSystem(audioSystem); // Sync............................. if (demoSettings.SyncEnabled) { syncSystem.Start(demoSettings.SyncFilePrefix); } else { syncSystem.StartManual(); } // Rendering ................. Size windowSize = new Size((int)demoSettings.Resolution.X, (int)demoSettings.Resolution.Y); base.Size = windowSize; if (demoSettings.Fullscreen) { base.WindowState = WindowState.Fullscreen; } renderer.ResizeScreen((int)demoSettings.Resolution.X, (int)demoSettings.Resolution.Y); CursorVisible = false; testScene = new TestScene(); testScene.Load(assetManager); loadingScene = new LoadingScene(); loadingScene.Load(assetManager); applicationTime = new Stopwatch(); LoadDemo(); Logger.LogPhase("OnLoad complete"); loadCompleted = true; running = true; applicationTime.Start(); }