public SentimentAnalysis(ILoggerFactory loggerFactory, IClient client, IDataSubscription <Document> dataSubscription)
 {
     logger                = loggerFactory?.CreateLogger <SentimentAnalysis>() ?? throw new ArgumentNullException(nameof(logger));
     this.client           = client ?? throw new ArgumentNullException(nameof(client));
     this.dataSubscription = dataSubscription ?? throw new ArgumentNullException(nameof(dataSubscription));
     subscription          = client.Messages.Subscribe(ProcessMessage);
     stateSubscription     = client.State.Where(item => item == ConnectionState.Error).Subscribe(item => completed.OnError(new Exception("Connection error")));
 }
Esempio n. 2
0
        public FateWatcher(CactbotEventSource client, string language, ILogger logger)
        {
            client_ = client;
            logger_ = logger;
            if (language == "ko")
            {
                region_ = "ko";
            }
            else if (language == "cn")
            {
                region_ = "cn";
            }
            else
            {
                region_ = "intl";
            }

            ready = false;

            fateSemaphore = new SemaphoreSlim(0, 1);
            ceSemaphore   = new SemaphoreSlim(0, 1);
            acselfopcodes = new Dictionary <string, ACSelfOPCodes>();
            acselfopcodes.Add("ko", acself_v5_2);
            acselfopcodes.Add("cn", acself_v5_2);
            acselfopcodes.Add("intl", acself_v5_2);

            cedirectoropcodes = new Dictionary <string, CEDirectorOPCodes>();
            cedirectoropcodes.Add("ko", cedirector_ko);
            cedirectoropcodes.Add("cn", cedirector_cn);
            cedirectoropcodes.Add("intl", cedirector_intl);

            fates = new Dictionary <int, int>();
            ces   = new Dictionary <int, CEDirectorData>();
            try {
                var FFXIV = GetPluginData();
                if (FFXIV != null)
                {
                    try {
                        subscription = (IDataSubscription)FFXIV.pluginObj.GetType().GetProperty("DataSubscription").GetValue(FFXIV.pluginObj);
                    } catch (Exception ex) {
                        logger.Log(LogLevel.Error, ex.ToString());
                    }
                }

                var mach = Assembly.Load("Machina.FFXIV");
                MessageType = mach.GetType("Machina.FFXIV.Headers.Server_MessageType");

                actorControlself  = new ActorControlSelf(MessageType, mach);
                headerOffset      = GetOffset(actorControlself.packetType, "MessageHeader");
                messageHeader     = actorControlself.packetType.GetField("MessageHeader").FieldType;
                messageTypeOffset = headerOffset + GetOffset(messageHeader, "MessageType");
                ready             = true;
            } catch (Exception e) {
                logger.Log(LogLevel.Error, "Error loading OPCodes, FATE info will be unavailable.");
                logger.Log(LogLevel.Error, "{0}\r\n{1}", e.Message, e.StackTrace);
            }
        }
Esempio n. 3
0
        public FateWatcher(CactbotEventSource client, string language)
        {
            client_ = client;
            if (language == "ko")
            {
                region_ = "ko";
            }
            else if (language == "cn")
            {
                region_ = "cn";
            }
            else
            {
                region_ = "intl";
            }

            fateSemaphore = new SemaphoreSlim(0, 1);
            ceSemaphore   = new SemaphoreSlim(0, 1);
            ac143opcodes  = new Dictionary <string, AC143OPCodes>();
            ac143opcodes.Add("ko", ac143_v5_2);
            ac143opcodes.Add("cn", ac143_v5_2);
            ac143opcodes.Add("intl", ac143_v5_2);

            cedirectoropcodes = new Dictionary <string, CEDirectorOPCodes>();
            cedirectoropcodes.Add("ko", cedirector_ko);
            cedirectoropcodes.Add("cn", cedirector_cn);
            cedirectoropcodes.Add("intl", cedirector_intl);

            fates = new Dictionary <int, int>();
            ces   = new Dictionary <int, CEDirectorData>();

            var FFXIV = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.lblPluginTitle.Text == "FFXIV_ACT_Plugin.dll");

            if (FFXIV != null && FFXIV.pluginObj != null)
            {
                try {
                    subscription = (IDataSubscription)FFXIV.pluginObj.GetType().GetProperty("DataSubscription").GetValue(FFXIV.pluginObj);
                } catch (Exception ex) {
                    client_.LogError(ex.ToString());
                }
            }

            var mach = Assembly.Load("Machina.FFXIV");

            MessageType = mach.GetType("Machina.FFXIV.Headers.Server_MessageType");

            actorControl143   = new ActorControl143(MessageType, mach);
            headerOffset      = GetOffset(actorControl143.packetType, "MessageHeader");
            messageHeader     = actorControl143.packetType.GetField("MessageHeader").FieldType;
            messageTypeOffset = headerOffset + GetOffset(messageHeader, "MessageType");
        }
Esempio n. 4
0
        public FateWatcher(CactbotEventSource client, string language)
        {
            client_ = client;
            if (language == "ko")
            {
                region_ = "ko";
            }
            else if (language == "cn")
            {
                region_ = "cn";
            }
            else
            {
                region_ = "intl";
            }

            opcodes = new Dictionary <string, OPCodes>();
            opcodes.Add("ko", v5_1);
            opcodes.Add("cn", v5_1);
            opcodes.Add("intl", v5_2);

            fates = new ConcurrentDictionary <int, int>();

            var FFXIV = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.lblPluginTitle.Text == "FFXIV_ACT_Plugin.dll");

            if (FFXIV != null && FFXIV.pluginObj != null)
            {
                try {
                    subscription = (IDataSubscription)FFXIV.pluginObj.GetType().GetProperty("DataSubscription").GetValue(FFXIV.pluginObj);
                } catch (Exception ex) {
                    client_.LogError(ex.ToString());
                }
            }

            var mach = Assembly.Load("Machina.FFXIV");

            MessageType          = mach.GetType("Machina.FFXIV.Headers.Server_MessageType");
            ActorControl143      = mach.GetType("Machina.FFXIV.Headers.Server_ActorControl143");
            ActorControl143_Size = Marshal.SizeOf(ActorControl143);

            Header_Offset = GetOffset(ActorControl143, "MessageHeader");
            msgHeader     = ActorControl143.GetField("MessageHeader").FieldType;

            MessageType_Offset = Header_Offset + GetOffset(msgHeader, "MessageType");

            Category_Offset = GetOffset(ActorControl143, "category");
            Param1_Offset   = GetOffset(ActorControl143, "param1");
            Param2_Offset   = GetOffset(ActorControl143, "param2");

            ActorControl143_Opcode = GetOpcode("ActorControl143");
        }
Esempio n. 5
0
        public void Start()
        {
            this.pluginSubscriber = new ThreadWorker(() =>
            {
                if (ActGlobals.oFormActMain == null)
                {
                    return;
                }

                if (this.plugin != null)
                {
                    return;
                }

                var ffxivPlugin = (
                    from x in ActGlobals.oFormActMain.ActPlugins
                    where
                    x.pluginFile.Name.ToUpper().Contains("FFXIV_ACT_Plugin".ToUpper()) &&
                    x.lblPluginStatus.Text.ToUpper().Contains("FFXIV Plugin Started.".ToUpper())
                    select
                    x.pluginObj).FirstOrDefault();

                if (ffxivPlugin != null)
                {
                    this.plugin           = ffxivPlugin;
                    this.DataRepository   = this.plugin.DataRepository;
                    this.DataSubscription = this.plugin.DataSubscription;

                    Logger.Info("FFXIV_ACT_Plugin attached.");
                }
            },
                                                     AttachSubscribeInterval,
                                                     "FFXIV_ACT_Plugin subscriber",
                                                     ThreadPriority.Lowest);

            this.pluginSubscriber.Run();

            this.combatantSubscriber = new ThreadWorker(
                this.DoRefreshCombatant,
                CombatantSubscribeInterval,
                "Combatant subscriber",
                ThreadPriority.Lowest);

            this.combatantSubscriber.Run();
        }
Esempio n. 6
0
        public void Stop()
        {
            if (this.pluginSubscriber != null)
            {
                this.pluginSubscriber.Abort();
                this.pluginSubscriber = null;
            }

            if (this.combatantSubscriber != null)
            {
                this.combatantSubscriber.Abort();
                this.combatantSubscriber = null;
            }

            this.plugin           = null;
            this.DataRepository   = null;
            this.DataSubscription = null;
        }
Esempio n. 7
0
        private IDataSubscription GetSubscription()
        {
            if (subscription != null)
            {
                return(subscription);
            }

            var FFXIV = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.lblPluginTitle.Text == "FFXIV_ACT_Plugin.dll");

            if (FFXIV != null && FFXIV.pluginObj != null)
            {
                try
                {
                    subscription = (IDataSubscription)FFXIV.pluginObj.GetType().GetProperty("DataSubscription").GetValue(FFXIV.pluginObj);
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, Resources.FFXIVDataSubscriptionException, ex);
                }
            }

            return(subscription);
        }
Esempio n. 8
0
        private IDataSubscription GetSubscription()
        {
            if (subscription != null)
            {
                return(subscription);
            }

            var FFXIV = GetPluginData();

            if (FFXIV != null)
            {
                try
                {
                    subscription = (IDataSubscription)FFXIV.pluginObj.GetType().GetProperty("DataSubscription").GetValue(FFXIV.pluginObj);
                }
                catch (Exception ex)
                {
                    logger.Log(LogLevel.Error, Resources.FFXIVDataSubscriptionException, ex);
                }
            }

            return(subscription);
        }
Esempio n. 9
0
        private static IDataSubscription GetSubscription()
        {
            if (subscription != null)
            {
                return(subscription);
            }

            var FFXIV = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.lblPluginTitle.Text == "FFXIV_ACT_Plugin.dll");

            if (FFXIV != null && FFXIV.pluginObj != null)
            {
                try
                {
                    subscription = (IDataSubscription)FFXIV.pluginObj.GetType().GetProperty("DataSubscription").GetValue(FFXIV.pluginObj);
                }
                catch (Exception ex)
                {
                    Registry.Resolve <ILogger>().Log(LogLevel.Error, $"Failed to retrieve the FFXIV DataSubscription: {ex}");
                }
            }

            return(subscription);
        }