public virtual void OnConnected(HPacket packet) { var hHost = packet.ReadUTF8(); var hPort = packet.ReadInt32(); ClientVersion = packet.ReadUTF8(); ClientIdentifier = packet.ReadUTF8(); ClientType = packet.ReadUTF8(); if (ClientType != "UNITY") { HotelServer = HotelEndPoint.Parse(hHost, hPort); } try { MessagesInfoIncoming = new List <HMessage>(); MessagesInfoOutgoing = new List <HMessage>(); if (ClientType == "UNITY") { UnityIn = new UnityIncoming(new List <HMessage>()); UnityOut = new UnityOutgoing(new List <HMessage>()); } else { Out = new Outgoing(new List <HMessage>()); In = new Incoming(new List <HMessage>()); } int MessagesInfoLenght = packet.ReadInt32(); foreach (var i in Enumerable.Range(0, MessagesInfoLenght)) { int CurrentMessageID = packet.ReadInt32(); string CurrentMessageHash = packet.ReadUTF8(); string CurrentMessageName = packet.ReadUTF8(); string CurrentMessageStructure = packet.ReadUTF8(); bool CurrentMessageIsOutgoing = packet.ReadBoolean(); string CurrentMessageSource = packet.ReadUTF8(); if (string.IsNullOrWhiteSpace(CurrentMessageHash) || CurrentMessageHash == "NULL") { CurrentMessageHash = CurrentMessageName; } CurrentMessageHash = CurrentMessageSource + "_" + CurrentMessageHash; HMessage CurrentHMessage = new HMessage((ushort)CurrentMessageID, CurrentMessageHash, CurrentMessageName, CurrentMessageStructure); if (CurrentMessageIsOutgoing) { MessagesInfoOutgoing.Add(CurrentHMessage); } else { MessagesInfoIncoming.Add(CurrentHMessage); } } List <HMessage> GeodeOut = new List <HMessage>(); List <HMessage> GeodeIn = new List <HMessage>(); if (ClientType == "UNITY") { foreach (PropertyInfo GeodeOutProperty in UnityOut.GetType().GetProperties()) { try { if (GeodeOutProperty.PropertyType == typeof(HMessage)) { var msgInfo = MessagesInfoOutgoing.FirstOrDefault(x => x.Name == GeodeOutProperty.Name); if (msgInfo != null) { GeodeOut.Add(msgInfo); } } } catch { Console.WriteLine("MessageInfo not found for: " + GeodeOutProperty.Name); } } foreach (PropertyInfo GeodeInProperty in UnityIn.GetType().GetProperties()) { try { if (GeodeInProperty.PropertyType == typeof(HMessage)) { var msgInfo = MessagesInfoIncoming.FirstOrDefault(x => x.Name == GeodeInProperty.Name); if (msgInfo != null) { GeodeIn.Add(msgInfo); } } } catch { Console.WriteLine("MessageInfo not found for: " + GeodeInProperty.Name); } } UnityOut = new UnityOutgoing(GeodeOut); UnityIn = new UnityIncoming(GeodeIn); } else { foreach (PropertyInfo GeodeOutProperty in Out.GetType().GetProperties()) { try { if (GeodeOutProperty.PropertyType == typeof(HMessage)) { GeodeOut.Add(MessagesInfoOutgoing.First(x => x.Name == GeodeOutProperty.Name)); } } catch { Console.WriteLine("MessageInfo not found for: " + GeodeOutProperty.Name); } } foreach (PropertyInfo GeodeInProperty in In.GetType().GetProperties()) { try { if (GeodeInProperty.PropertyType == typeof(HMessage)) { GeodeIn.Add(MessagesInfoIncoming.First(x => x.Name == GeodeInProperty.Name)); } } catch { Console.WriteLine("MessageInfo not found for: " + GeodeInProperty.Name); } } Out = new Outgoing(GeodeOut); In = new Incoming(GeodeIn); } } catch (Exception ex) { Console.WriteLine("Critical MessagesInfo exception: " + ex.Message); MessagesInfo_Failed = true; } ResolveCallbacks(); IsConnected = true; if (DisableEventHandlers == false) { try { OnConnectedEvent.Invoke(this, packet); } catch { };//Invoke event handler } }