コード例 #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)));
                }
            }
        }