public void SetupDicts(Packet p) { SerializeReader.FromBinary <Object>(p, out Object obj); String contents = obj.ToString(); if (contents.StartsWith("TypeConverter")) { MatchCollection mc = Regex.Matches(contents, @"0x([A-F0-9]+)[,\s\{]*FullName = ([A-Za-z\._]+), GUID = ([a-z0-9-]+)"); Dictionary <String, bool> loaded = new Dictionary <String, bool>(); foreach (Match m in mc) { int categoryId = int.Parse(m.Groups[1].ToString(), System.Globalization.NumberStyles.HexNumber); String className = m.Groups[2].ToString(); Guid guid = Guid.Parse(m.Groups[3].ToString()); if (classNames.TryGetValue(categoryId, out string dictClassName)) { if (dictClassName != null && dictClassName != className) { Console.WriteLine("Error! Conflicting types going to dictionaries, please remove the static keyword"); } } else { classNames.Add(categoryId, className); getGuid.Add(categoryId, guid); } } } Console.WriteLine("Have {0} types in dict", classNames.Count); }
public void ProcessTypeConverter(Devcat.Core.Net.Message.Packet p) { SerializeReader.FromBinary <Object>(p, out Object obj); String s1 = obj.ToString(); SetupDicts(s1); mp.RegisterPrinters(mf, getGuid); }
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))); } } }
private void AddCommandLogging(Packet packet, User user) { try { StandardInProcessMessage standardInProcessMessage = null; SerializeReader.FromBinary <StandardInProcessMessage>(packet, out standardInProcessMessage); if (standardInProcessMessage != null && standardInProcessMessage.Name.CompareTo("HeroesCommandBridge") == 0) { Log <ControlServer> .Logger.InfoFormat(standardInProcessMessage.Message + string.Format(" Written By [{0}].", user.AccountId), new object[0]); } } catch (SerializationException) { } catch (Exception ex) { Log <ControlServer> .Logger.Error(ex); } }