public static void AddFrame(WsFrame frame, CommPacketDirection direction, ConnectionInstance connectionInstance)
        {
            if (instance == null || !instance.Data.CaptureEnabled)
            {
                return;
            }

            try
            {
                var parentPacket = new CommPacket
                {
                    Data         = frame.HeaderBytes,
                    Direction    = direction,
                    Id           = Guid.NewGuid(),
                    Instance     = connectionInstance,
                    ParentPacket = null,
                    Header       = "Websocket Frame",
                };

                foreach (var curMessage in frame.Messages)
                {
                    var headerPacket = new CommPacket
                    {
                        Data         = BitConverter.GetBytes((ushort)(curMessage.Buffer.Length + 1)).Concat(new byte[] { curMessage.ApiId ?? 0 }).ToArray(),
                        Direction    = direction,
                        Id           = Guid.NewGuid(),
                        Instance     = connectionInstance,
                        ParentPacket = parentPacket,
                        Header       = $"Websocket Message[0x{curMessage.ApiId ?? 0:X2}]",
                    };

                    var payloadPacket = new CommPacket
                    {
                        Data         = curMessage.Buffer,
                        Direction    = direction,
                        Id           = Guid.NewGuid(),
                        Instance     = connectionInstance,
                        ParentPacket = parentPacket,
                        Header       = $"Websocket Payload",
                    };

                    headerPacket.ChildPackets.Add(payloadPacket);
                    parentPacket.ChildPackets.Add(headerPacket);
                }
                ;

                instance.Data.SendBytesToUi(connectionInstance, parentPacket);
            }
            catch (Exception ex) {
                Log.Error(ex, "Error in AddFrame");
            }
        }
        public static void SendBytesToUi(ConnectionInstance connectionInstance, CommPacket packet)
        {
            if (instance == null || !instance.Data.CaptureEnabled)
            {
                return;
            }

            try
            {
                instance.Data.SendBytesToUi(connectionInstance, packet);
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error in SendBytesToUi");
            }
        }
        private void GotoSearchPacket(CommPacket packet)
        {
            m_dontMainSelect = true;

            Dispatcher.Invoke(new Action(() =>
            {
                lstGroups.SelectedItem    = packet.Instance.Parent;
                lstInstances.SelectedItem = packet.Instance;

                ItemContainerGenerator doExpand(CommPacket curPacket)
                {
                    ItemContainerGenerator result = null;

                    if (curPacket.ParentPacket != null)
                    {
                        result = doExpand(curPacket.ParentPacket);
                    }

                    if (result == null)
                    {
                        result = lstPackets.ItemContainerGenerator;
                    }

                    var curItem = result.ContainerFromItem(curPacket) as TreeViewItem;

                    if (curItem != null)
                    {
                        curItem.IsSelected = true;
                        curItem.ExpandSubtree();
                        curItem.BringIntoView();

                        return(curItem.ItemContainerGenerator);
                    }
                    else
                    {
                        return(null);
                    }
                }

                doExpand(packet);
            }));

            m_dontMainSelect = false;
        }