public void TestCleanup()
 {
     _apiClient     = null;
     _userStorage   = null;
     _serverUpdater = null;
     _appSettings   = null;
     _logger        = null;
     _serverManager = null;
 }
 public ConnectionErrorResolver(
     IUserStorage userStorage,
     IApiClient api,
     ServerManager serverManager,
     IServerUpdater serverUpdater)
 {
     _serverUpdater = serverUpdater;
     _serverManager = serverManager;
     _userStorage   = userStorage;
     _api           = api;
 }
Example #3
0
        public ServerInstance(BuildModel build, IServerUpdater updater, IByondWrapper byond, IOptions <Config> config, ILogger <ServerInstance> logger)
        {
            string serverAddress = config.Value.Hub.Address;

            Build  = build;
            Status = new ServerStatusResult()
            {
                IsRunning = false, IsUpdating = false, Address = serverAddress, Id = build.Id
            };
            State   = new StoppedServerState(this);
            _byond  = byond;
            _logger = logger;
            _playersUpdatedTimestamp = DateTime.Now;
            _updater = updater;
        }
Example #4
0
        public void TestInitialize()
        {
            _apiClient     = Substitute.For <IApiClient>();
            _userStorage   = Substitute.For <IUserStorage>();
            _serverUpdater = Substitute.For <IServerUpdater>();
            _serverManager = Substitute.For <ServerManager>(_userStorage);

            var result = ApiResponseResult <VpnInfoResponse> .Ok(new VpnInfoResponse
            {
                Code  = 1000,
                Error = string.Empty
            });

            _apiClient.GetVpnInfoResponse().Returns(Task.FromResult(result));
        }
 private void SetupPlaylistReactions(IServerUpdater r)
 {
     r.ObserveTrackAdd += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.TrackAddEventArgs>)AddItem, sender, e);
         }
         else
         {
             AddItem(sender, e);
         }
     };
     r.ObserveTrackMove += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.TrackMoveEventArgs>)MoveItemTo, sender, e);
         }
         else
         {
             MoveItemTo(sender, e);
         }
     };
     r.ObserveTrackDelete += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.TrackDeleteEventArgs>)DeleteItem, sender, e);
         }
         else
         {
             DeleteItem(sender, e);
         }
     };
     r.ObservePlaylistReset += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.PlaylistResetEventArgs>)CleanPlaylist, sender, e);
         }
         else
         {
             CleanPlaylist(sender, e);
         }
     };
 }
Example #6
0
        public ReconnectManager(
            IVpnConfig config,
            IApiClient apiClient,
            ProfileManager profileManager,
            ServerManager serverManager,
            IVpnManager vpnManager,
            IScheduler scheduler,
            IServerUpdater serverUpdater)
        {
            _config         = config;
            _serverUpdater  = serverUpdater;
            _serverManager  = serverManager;
            _vpnManager     = vpnManager;
            _profileManager = profileManager;
            _apiClient      = apiClient;

            _timer       = scheduler.Timer();
            _timer.Tick += OnTimerTick;
        }
Example #7
0
        public ReconnectManager(
            IAppSettings appSettings,
            IApiClient apiClient,
            ProfileManager profileManager,
            ServerManager serverManager,
            IVpnManager vpnManager,
            IScheduler scheduler,
            IServerUpdater serverUpdater)
        {
            _appSettings    = appSettings;
            _serverUpdater  = serverUpdater;
            _serverManager  = serverManager;
            _vpnManager     = vpnManager;
            _profileManager = profileManager;
            _apiClient      = apiClient;

            _timer       = scheduler.Timer();
            _timer.Tick += OnTimerTick;
        }
Example #8
0
 private void SetupDatabaseReactions(IServerUpdater r)
 {
     r.ObserveLibraryResult += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((Action <uint, int, string>)addLibraryResult, e.resultID, (int)e.dirtyStatus, e.description);
         }
         else
         {
             addLibraryResult(e.resultID, e.dirtyStatus, e.description);
         }
     };
     r.ObserveShowResult += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((Action <uint, string>)addShowResult, e.showID, e.description);
         }
         else
         {
             addShowResult(e.showID, e.description);
         }
     };
     r.ObserveListingResult += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((Action <uint, uint, string>)addListingResult, e.listingID, e.channelID, e.description);
         }
         else
         {
             addListingResult(e.listingID, e.channelID, e.description);
         }
     };
 }
 private void SetupPlaybackReactions(IServerUpdater r)
 {
     r.ObservePlayerState += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.PlayerStateEventArgs>)ShowChannelOperation, sender, e);
         }
         else
         {
             ShowChannelOperation(sender, e);
         }
     };
     r.ObserveMarker += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.MarkerEventArgs>)ShowPositionWithType, sender, e);
         }
         else
         {
             ShowPositionWithType(sender, e);
         }
     };
     r.ObserveTrackLoad += (sender, e) =>
     {
         if (InvokeRequired)
         {
             Invoke((EventHandler <Updates.TrackLoadEventArgs>)ShowLoadedItem, this, e);
         }
         else
         {
             ShowLoadedItem(this, e);
         }
     };
 }
        private void SetupSystemReactions(IServerUpdater r)
        {
            r.ObserveDirectoryFileAdd += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((EventHandler <Updates.DirectoryFileAddEventArgs>)addFileToDirectoryList, sender, e);
                }
                else
                {
                    addFileToDirectoryList(sender, e);
                }
            };
            r.ObserveDirectoryPrepare += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((EventHandler <Updates.DirectoryPrepareEventArgs>)clearFiles, sender, e);
                }
                else
                {
                    clearFiles(sender, e);
                }
            };
            r.ObserveVersion += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((Action <string, string, string, string>)displayVersion, e.Version, e.Date, e.Time, e.Author);
                }
                else
                {
                    displayVersion(e.Version, e.Date, e.Time, e.Author);
                }
            };
            r.ObserveTextScroll += (sender, e) =>
            {
                var td = textDialog;
                if (td == null)
                {
                    return;
                }
                if (td.InvokeRequired)
                {
                    td.Invoke((Action <int>)td.scroll, (int)e);
                }
                else
                {
                    td.textSize((int)e);
                }
            };
            r.ObserveTextSizeChange += (sender, e) =>
            {
                var td = textDialog;
                if (td == null)
                {
                    return;
                }
                if (td.InvokeRequired)
                {
                    td.Invoke((Action <int>)td.textSize, (int)e);
                }
                else
                {
                    td.textSize((int)e);
                }
            };
            r.ObserveServerQuit += (sender, e) =>
            {
                var description = "The server is shutting down/restarting.";

                if (InvokeRequired)
                {
                    Invoke((Action <string, bool>)SendQuit, description, e);
                }
                else
                {
                    SendQuit(description, e);
                }
            };
        }
        private void SetupConfigReactions(IServerUpdater r)
        {
            Config.SubscribeToReceiver(r);

            r.ObserveConfigOption += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((EventHandler <Updates.ConfigOptionEventArgs>)processOption, sender, e);
                }
                else
                {
                    processOption(sender, e);
                }
            };
            r.ObserveConfigChoice += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((EventHandler <Updates.ConfigChoiceEventArgs>)processChoice, sender, e);
                }
                else
                {
                    processChoice(sender, e);
                }
            };
            r.ObserveConfigSetting += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((EventHandler <Updates.ConfigSettingEventArgs>)processConfigSetting, sender, e);
                }
                else
                {
                    processConfigSetting(sender, e);
                }
            };
            r.ObserveConfigResult += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((Action <Command, uint, ConfigResult>)processConfigResult, e.cmdReceived, e.optionID, e.result);
                }
                else
                {
                    processConfigResult(e.cmdReceived, e.optionID, e.result);
                }
            };
            r.ObserveUser += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((Action <string, uint>)processUserInfo, e.username, e.permissions);
                }
                else
                {
                    processUserInfo(e.username, e.permissions);
                }
            };
            r.ObservePermission += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((Action <uint, string>)processPermissionInfo, e.permissionCode, e.description);
                }
                else
                {
                    processPermissionInfo(e.permissionCode, e.description);
                }
            };
            r.ObserveUserResult += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((Action <uint, string>)processUserResult, e.resultCode, e.description);
                }
                else
                {
                    processUserResult(e.resultCode, e.description);
                }
            };
            r.ObserveIpRestriction += (sender, e) =>
            {
                if (InvokeRequired)
                {
                    Invoke((Action <Command, string, uint>)processIPRestriction, e.cmdReceived, e.ipAddress, e.mask);
                }
                else
                {
                    processIPRestriction(e.cmdReceived, e.ipAddress, e.mask);
                }
            };
        }