Example #1
0
        public SyncPlugin()
        {
            ConfigService.Load();
            var wsClient = new DomainWebsocketClient(ConfigService.GetWsUrl());

            this.syncService = new SyncService(wsClient);
            this.syncService.OnSyncModeChanged += OnSyncModeChanged;
        }
        public async Task HandleParallelCalls()
        {
            var client      = new DomainWebsocketClient(ConfigService.GetWsUrl());
            var syncService = new SyncService(client);

            syncService.SetSessionId("test-session");
            syncService.PlayerName = "test-player";
            var rnd   = new Random();
            var tasks = Enumerable.Range(1, 5)
                        .Select(i => Task.Run(async() =>
            {
                while (true)
                {
                    var val  = rnd.Next(0, 100);
                    var mode = val switch
                    {
                        < 40 => SyncServiceMode.Poll,
                        < 80 => SyncServiceMode.Push,
                        _ => SyncServiceMode.Idle
                    };
                    Logger.Debug($"  --> {mode:G}");
                    syncService.SetMode(mode);
                    await Task.Delay(i * 30);
                }