示例#1
0
        private void ProcessClientMessage(Packet packet, RCClient client)
        {
            Type type = this.MF.GetType(packet);

            if (type == typeof(AddProcessMessage))
            {
                AddProcessMessage addProcessMessage;
                SerializeReader.FromBinary <AddProcessMessage>(packet, out addProcessMessage);
                client.ProcessMessage(addProcessMessage);
                this.CheckAndAddHeroesAdmin(client.ID, client.ClientIP, addProcessMessage.Process);
                return;
            }
            if (type == typeof(ModifyProcessMessage))
            {
                ModifyProcessMessage modifyProcessMessage;
                SerializeReader.FromBinary <ModifyProcessMessage>(packet, out modifyProcessMessage);
                client.ProcessMessage(modifyProcessMessage);
                this.CheckAndAddHeroesAdmin(client.ID, client.ClientIP, modifyProcessMessage.Process);
                return;
            }
            if (type == typeof(RemoveProcessMessage))
            {
                RemoveProcessMessage removeProcessMessage;
                SerializeReader.FromBinary <RemoveProcessMessage>(packet, out removeProcessMessage);
                client.ProcessMessage(removeProcessMessage);
                this.CheckAndRemoveHeroesAdmin(client.ID, removeProcessMessage.Name);
                return;
            }
            if (type == typeof(StateChangeProcessMessage))
            {
                StateChangeProcessMessage stateChangeProcessMessage;
                SerializeReader.FromBinary <StateChangeProcessMessage>(packet, out stateChangeProcessMessage);
                if (this.serverGroups.ContainsKey(client.ID) && stateChangeProcessMessage.State == RCProcess.ProcessState.On)
                {
                    string processKey = this.GetProcessKey(client.ID, stateChangeProcessMessage.Name);
                    if (this.serverGroups[client.ID].ContainsKey(processKey))
                    {
                        string value = this.serverGroups[client.ID][processKey];
                        if (this.ServerGroupActivated != null)
                        {
                            this.ServerGroupActivated(this, new EventArgs <string>(value));
                            return;
                        }
                    }
                }
            }
            else if (type == typeof(LogProcessMessage))
            {
                LogProcessMessage logProcessMessage;
                SerializeReader.FromBinary <LogProcessMessage>(packet, out logProcessMessage);
                RCProcess rcprocess = client[logProcessMessage.Name];
                if ((rcprocess.PerformanceString.Length == 0 || !RCProcess.IsStandardOutputLog(logProcessMessage.Message) || !RCProcess.GetOriginalLog(logProcessMessage.Message).StartsWith(rcprocess.PerformanceString)) && this.ProcessLogged != null)
                {
                    this.ProcessLogged(new KeyValuePair <RCClient, RCProcess>(client, rcprocess), new EventArgs <string>(RCProcess.GetOriginalLog(logProcessMessage.Message)));
                }
            }
        }
示例#2
0
 private void RCUserHandler_ProcessLog(RCClient sender, RCClient.ProcessLogEventArgs args)
 {
     if (this.userCounts.ContainsKey(args.Process) && args.Process.PerformanceString.Length > 0 && RCProcess.IsStandardOutputLog(args.Message) && args.Process.IsPerformanceLog(args.Message) && this.UserCountLogged != null)
     {
         this.UserCountLogged(args.Process, new EventArgs <string>(args.Process.GetPerformanceLog(args.Message)));
     }
 }
示例#3
0
        private void Client_ProcessLog(RCClient sender, RCClient.ProcessLogEventArgs args)
        {
            this.SendMessageToControlServer <LogProcessMessage>(new LogProcessMessage(args.Process.Name, args.Message));
            if (args.Process.PerformanceString.Length > 0 && RCProcess.IsStandardOutputLog(args.Message) && RCProcess.GetOriginalLog(args.Message).StartsWith(args.Process.PerformanceString))
            {
                string categoryName = "RCClient." + args.Process.Name;
                RCProcess.PerformanceDescriptionParser[] fromRawString = RCProcess.PerformanceDescriptionParser.GetFromRawString(args.Process.PerformanceDescription);
                string[] array = RCProcess.GetOriginalLog(args.Message).Substring(args.Process.PerformanceString.Length).Trim().Split(new char[]
                {
                    ' '
                });
                int    num    = Math.Min(array.Length, fromRawString.Length);
                long[] array2 = new long[num];
                for (int i = 0; i < num; i++)
                {
                    try
                    {
                        array2[i] = long.Parse(array[i]);
                    }
                    catch (Exception)
                    {
                        array2[i] = 0L;
                    }
                }
                bool flag = false;
                do
                {
                    try
                    {
                        for (int j = 0; j < num; j++)
                        {
                            new PerformanceCounter(categoryName, fromRawString[j].Name, false).RawValue = array2[j];
                        }
                        flag = false;
                    }
                    catch (Exception ex)
                    {
                        Log <RCClientService> .Logger.ErrorFormat("ExceptionRcClient: {0}", ex.ToString());

                        if (flag)
                        {
                            if (ex is Win32Exception)
                            {
                                Log <RCClientService> .Logger.ErrorFormat("Performance monitor unexcepted exception : {0}\n{1}", ((Win32Exception)ex).NativeErrorCode, ex.Message);
                            }
                            else
                            {
                                Log <RCClientService> .Logger.Error("Performance monitor unexcepted exception :", ex);
                            }
                            break;
                        }
                        flag = true;
                        if (PerformanceCounterCategory.Exists(categoryName))
                        {
                            PerformanceCounterCategory.Delete(categoryName);
                        }
                        CounterCreationDataCollection counterCreationDataCollection = new CounterCreationDataCollection();
                        foreach (RCProcess.PerformanceDescriptionParser performanceDescriptionParser in fromRawString)
                        {
                            counterCreationDataCollection.Add(new CounterCreationData(performanceDescriptionParser.Name, performanceDescriptionParser.HelpMessage, PerformanceCounterType.NumberOfItems64));
                        }
                        PerformanceCounterCategory.Create(categoryName, "", PerformanceCounterCategoryType.SingleInstance, counterCreationDataCollection);
                    }
                }while (flag);
            }
        }