Example #1
0
        private void BNetBufferAssembledCallback(byte[] buffer, Direction direction, string clientHash)
        {
            Dictionary <string, Color[]> colors = new Dictionary <string, Color[]>();


            Color[][] trafficColors = new Color[][]
            { new Color[] { Color.LightCoral, Color.LightBlue },
              new Color[] { Color.Tomato, Color.Blue },
              new Color[] { Color.Red, Color.BlueViolet },
              new Color[] { Color.PaleVioletRed, Color.CadetBlue } };


            var stream = CodedInputStream.CreateInstance(buffer);

            while (!stream.IsAtEnd)
            {
                try
                {
                    var packet = new PacketIn(null, null);

                    if (packet.Header.ServiceId == 0xFE /*ServiceReply*/)
                    {
                        //ProcessReply(client, packet);
                        var callNode = RPCCallbacksIn[packet.Header.Token];
                        RPCCallbacksIn.Remove(packet.Header.Token);
                        callNode.ReceiveReply(packet, true);
                    }
                    else
                    {
                        var service = Service.GetByID(packet.Header.ServiceId);

                        if (service == null)
                        {
                            MooNetTree.Nodes.Add(String.Format("Service not found: {0}", service));
                            return;
                        }

                        var newNode = new MooNetCallNode(packet, stream);
                        MooNetTree.Nodes.Add(newNode);
                        RPCCallbacksIn.Add(packet.Header.Token, newNode);
                    }
                }
                catch (Exception e)
                {
                    var newNode = new TreeNode(String.Format("Error parsing {0}", e.Message));
                    MooNetTree.Nodes.Add(newNode);
                }
            }
        }
        private void BNetBufferAssembledCallback(byte[] buffer, Direction direction, string clientHash)
        {
            Dictionary<string, Color[]> colors = new Dictionary<string, Color[]>();


            Color[][] trafficColors = new Color[][]
            { new Color[] { Color.LightCoral , Color.LightBlue },
              new Color[] { Color.Tomato, Color.Blue },
              new Color[] { Color.Red, Color.BlueViolet },
              new Color[] { Color.PaleVioletRed, Color.CadetBlue } 
            };


            var stream = CodedInputStream.CreateInstance(buffer);
            while (!stream.IsAtEnd)
            {
                try
                {
                    var packet = new PacketIn(null, stream);

                    if (packet.Header.ServiceId == 0xFE /*ServiceReply*/)
                    {
                        //ProcessReply(client, packet);
                        var callNode = RPCCallbacksIn[packet.Header.Token];
                        RPCCallbacksIn.Remove(packet.Header.Token);
                        callNode.ReceiveReply(packet, true);
                    }
                    else
                    {
                        var service = Service.GetByID(packet.Header.ServiceId);

                        if (service == null)
                        {
                            MooNetTree.Nodes.Add(String.Format("Service not found: {0}", service));
                            return;
                        }

                        var newNode = new MooNetCallNode(packet, stream);
                        MooNetTree.Nodes.Add(newNode);
                        RPCCallbacksIn.Add(packet.Header.Token, newNode);
                    }
                }
                catch (Exception e)
                {
                    var newNode = new TreeNode(String.Format("Error parsing {0}", e.Message));
                    MooNetTree.Nodes.Add(newNode);
                
                }
            }
        }