public void Setup() { eventAggregator = new InternalEventAggregator(); receiver = new Subscriber <TestMessage>(eventAggregator); //receiver = new MessageReceiver(eventAggregator); invoker = new InternalEventInvoker(eventAggregator, logger, new ThreadPoolMarshaller(logger)) { LoopDelayMillis = 1 }; }
internal static Dictionary <Type, List <IListener> > GetListeners(InternalEventAggregator ea) { return(GetInstanceField(typeof(InternalEventAggregator), ea, "listeners") as Dictionary <Type, List <IListener> >); }
public WurmCharacter([NotNull] CharacterName name, [NotNull] string playerDirectoryFullPath, [NotNull] IWurmConfigs wurmConfigs, [NotNull] IWurmServers wurmServers, [NotNull] IWurmServerHistory wurmServerHistory, [NotNull] IWurmApiLogger logger, [NotNull] TaskManager taskManager, [NotNull] IWurmLogsMonitorInternal logsMonitor, [NotNull] IPublicEventInvoker publicEventInvoker, [NotNull] InternalEventAggregator internalEventAggregator, [NotNull] IWurmLogsHistory logsHistory, [NotNull] IWurmPaths wurmPaths, [NotNull] IWurmServerGroups wurmServerGroups) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (playerDirectoryFullPath == null) { throw new ArgumentNullException(nameof(playerDirectoryFullPath)); } if (wurmConfigs == null) { throw new ArgumentNullException(nameof(wurmConfigs)); } if (wurmServers == null) { throw new ArgumentNullException(nameof(wurmServers)); } if (wurmServerHistory == null) { throw new ArgumentNullException(nameof(wurmServerHistory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (taskManager == null) { throw new ArgumentNullException(nameof(taskManager)); } if (logsMonitor == null) { throw new ArgumentNullException(nameof(logsMonitor)); } if (publicEventInvoker == null) { throw new ArgumentNullException(nameof(publicEventInvoker)); } if (internalEventAggregator == null) { throw new ArgumentNullException(nameof(internalEventAggregator)); } if (logsHistory == null) { throw new ArgumentNullException(nameof(logsHistory)); } if (wurmPaths == null) { throw new ArgumentNullException(nameof(wurmPaths)); } if (wurmServerGroups == null) { throw new ArgumentNullException(nameof(wurmServerGroups)); } this.wurmConfigs = wurmConfigs; this.wurmServers = wurmServers; this.wurmServerHistory = wurmServerHistory; this.logger = logger; this.taskManager = taskManager; this.logsMonitor = logsMonitor; this.publicEventInvoker = publicEventInvoker; this.internalEventAggregator = internalEventAggregator; this.logsHistory = logsHistory; this.wurmServerGroups = wurmServerGroups; internalEventAggregator.Subscribe(this); Name = name; configDefiningFileFullPath = Path.Combine(playerDirectoryFullPath, ConfigDefinerFileName); RefreshCurrentConfig(); configUpdateTask = new TaskHandle(RefreshCurrentConfig, "Current config update for player " + Name); taskManager.Add(configUpdateTask); configFileWatcher = new FileSystemWatcher(playerDirectoryFullPath) { Filter = ConfigDefinerFileName }; configFileWatcher.Changed += ConfigFileWatcherOnChanged; configFileWatcher.Created += ConfigFileWatcherOnChanged; configFileWatcher.Deleted += ConfigFileWatcherOnChanged; configFileWatcher.Renamed += ConfigFileWatcherOnChanged; configFileWatcher.EnableRaisingEvents = true; configUpdateTask.Trigger(); try { wurmServerHistory.BeginTracking(Name); } catch (Exception exception) { logger.Log(LogLevel.Error, string.Format("Failed to initiate tracking of server history for character {0}", name), this, exception); } skills = new WurmCharacterSkills(this, publicEventInvoker, logsMonitor, logsHistory, logger, wurmPaths, internalEventAggregator); Logs = new WurmCharacterLogs(this, wurmServerGroups, logsHistory, wurmServers, logger); }
public UnsubscribeTester() { var syncContexts = new SynchronizationContext(); eventAggregator = new InternalEventAggregator(syncContexts); }
public WurmCharacters([NotNull] IWurmCharacterDirectories characterDirectories, [NotNull] IWurmConfigs wurmConfigs, [NotNull] IWurmServers wurmServers, [NotNull] IWurmServerHistory wurmServerHistory, [NotNull] IWurmApiLogger logger, [NotNull] TaskManager taskManager, [NotNull] IWurmLogsMonitorInternal wurmLogsMonitor, [NotNull] IPublicEventInvoker publicEventInvoker, [NotNull] InternalEventAggregator internalEventAggregator, [NotNull] IWurmPaths wurmPaths, [NotNull] IWurmLogsHistory wurmLogsHistory, [NotNull] IWurmServerGroups serverGroups) { this.characterDirectories = characterDirectories; this.wurmConfigs = wurmConfigs; this.wurmServers = wurmServers; this.wurmServerHistory = wurmServerHistory; this.logger = logger; this.taskManager = taskManager; this.wurmLogsMonitor = wurmLogsMonitor; this.publicEventInvoker = publicEventInvoker; this.internalEventAggregator = internalEventAggregator; this.wurmPaths = wurmPaths; this.wurmLogsHistory = wurmLogsHistory; this.serverGroups = serverGroups; if (characterDirectories == null) { throw new ArgumentNullException(nameof(characterDirectories)); } if (wurmConfigs == null) { throw new ArgumentNullException(nameof(wurmConfigs)); } if (wurmServers == null) { throw new ArgumentNullException(nameof(wurmServers)); } if (wurmServerHistory == null) { throw new ArgumentNullException(nameof(wurmServerHistory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (taskManager == null) { throw new ArgumentNullException(nameof(taskManager)); } if (wurmLogsMonitor == null) { throw new ArgumentNullException(nameof(wurmLogsMonitor)); } if (publicEventInvoker == null) { throw new ArgumentNullException(nameof(publicEventInvoker)); } if (internalEventAggregator == null) { throw new ArgumentNullException(nameof(internalEventAggregator)); } if (wurmPaths == null) { throw new ArgumentNullException(nameof(wurmPaths)); } if (wurmLogsHistory == null) { throw new ArgumentNullException(nameof(wurmLogsHistory)); } if (serverGroups == null) { throw new ArgumentNullException(nameof(serverGroups)); } var allChars = characterDirectories.GetAllCharacters(); foreach (var characterName in allChars) { try { Create(characterName); } catch (Exception exception) { logger.Log(LogLevel.Error, string.Format("Could not initialize character for name {0}", characterName), this, exception); } } }
void ConstructSystems(string wurmApiDataDirectoryFullPath, IWurmClientInstallDirectory installDirectory, IHttpWebRequests httpWebRequests, IWurmApiLogger logger, IWurmApiEventMarshaller publicEventMarshaller, IWurmApiEventMarshaller internalEventMarshaller, WurmApiConfig wurmApiConfig) { IWurmApiConfig internalWurmApiConfig = wurmApiConfig.CreateCopy(); LogFileStreamReaderFactory logFileStreamReaderFactory = Wire(new LogFileStreamReaderFactory(internalWurmApiConfig)); Wire(installDirectory); Wire(httpWebRequests); if (logger == null) { logger = new WurmApiLoggerStub(); } PublicEventInvoker publicEventInvoker = Wire(new PublicEventInvoker(publicEventMarshaller, logger)); TaskManager taskManager = Wire(new TaskManager(logger)); InternalEventAggregator internalEventAggregator = Wire(new InternalEventAggregator()); InternalEventInvoker internalEventInvoker = Wire(new InternalEventInvoker(internalEventAggregator, logger, internalEventMarshaller)); WurmPaths paths = Wire(new WurmPaths(installDirectory, wurmApiConfig)); WurmServerGroups serverGroups = Wire(new WurmServerGroups(internalWurmApiConfig.ServerInfoMap)); WurmServerList serverList = Wire(new WurmServerList(internalWurmApiConfig.ServerInfoMap)); WurmLogDefinitions logDefinitions = Wire(new WurmLogDefinitions()); WurmConfigDirectories configDirectories = Wire(new WurmConfigDirectories(paths, internalEventAggregator, taskManager, logger)); WurmCharacterDirectories characterDirectories = Wire(new WurmCharacterDirectories(paths, internalEventAggregator, taskManager, logger)); WurmLogFiles logFiles = Wire(new WurmLogFiles(characterDirectories, logger, logDefinitions, internalEventAggregator, internalEventInvoker, taskManager, paths)); WurmLogsMonitor logsMonitor = Wire(new WurmLogsMonitor(logFiles, logger, publicEventInvoker, internalEventAggregator, characterDirectories, internalEventInvoker, taskManager, logFileStreamReaderFactory)); var heuristicsDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmLogsHistory"); if (internalWurmApiConfig.ClearAllCaches) { ClearDir(heuristicsDataDirectory, logger); } WurmLogsHistory logsHistory = Wire(new WurmLogsHistory(logFiles, logger, heuristicsDataDirectory, logFileStreamReaderFactory, wurmApiConfig)); WurmConfigs wurmConfigs = Wire(new WurmConfigs(configDirectories, logger, publicEventInvoker, internalEventAggregator, taskManager)); WurmAutoruns autoruns = Wire(new WurmAutoruns(wurmConfigs, characterDirectories, logger)); var wurmServerHistoryDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmServerHistory"); if (internalWurmApiConfig.ClearAllCaches) { ClearDir(wurmServerHistoryDataDirectory, logger); } WurmServerHistory wurmServerHistory = Wire(new WurmServerHistory(wurmServerHistoryDataDirectory, logsHistory, serverList, logger, logsMonitor, logFiles, internalEventAggregator, serverGroups, wurmApiConfig)); var wurmServersDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmServers"); if (internalWurmApiConfig.ClearAllCaches) { ClearDir(wurmServersDataDirectory, logger); } WurmServers wurmServers = Wire(new WurmServers(logsHistory, logsMonitor, serverList, httpWebRequests, wurmServersDataDirectory, characterDirectories, wurmServerHistory, logger, serverGroups, wurmApiConfig)); WurmCharacters characters = Wire(new WurmCharacters(characterDirectories, wurmConfigs, wurmServers, wurmServerHistory, logger, taskManager, logsMonitor, publicEventInvoker, internalEventAggregator, paths, logsHistory, serverGroups)); HttpWebRequests = httpWebRequests; Autoruns = autoruns; Characters = characters; Configs = wurmConfigs; LogDefinitions = logDefinitions; LogsHistory = logsHistory; LogsMonitor = logsMonitor; Servers = wurmServers; WurmLogFiles = logFiles; WurmServerHistory = wurmServerHistory; WurmCharacterDirectories = characterDirectories; WurmConfigDirectories = configDirectories; InternalEventAggregator = internalEventAggregator; Paths = paths; ServerGroups = serverGroups; Logger = logger; ServersList = serverList; }