Ejemplo n.º 1
0
    void ProxyManager_OnMessageLog(GridProxy.CapsRequest req, GridProxy.CapsStage stage)
    {
        Application.Invoke((sender, e) =>
        {
            if (CapFilterItems.ContainsKey(req.Info.CapType))
            {
                var filter = CapFilterItems[req.Info.CapType];
                if (!filter.Enabled) return;

                PacketCounter++;

                int size = 0;
                if (req.RawRequest != null)
                {
                    size += req.RawRequest.Length;
                }

                if (req.RawResponse != null)
                {
                    size += req.RawResponse.Length;
                }

                GridProxy.Direction direction;
                if (stage == GridProxy.CapsStage.Request)
                {
                    CapsOutCounter++;
                    CapsOutBytes += req.Request.ToString().Length;
                    direction = GridProxy.Direction.Outgoing;
                }
                else
                {
                    CapsInCounter++;
                    CapsInBytes += req.Response.ToString().Length;
                    direction = GridProxy.Direction.Incoming;
                }

                string proto = filter.Type.ToString();

                Session capsSession = null;
                if (filter.Type == ItemType.Cap)
                {
                    capsSession = new SessionCaps(req.RawRequest, req.RawResponse, req.RequestHeaders,
                    req.ResponseHeaders, direction, req.Info.URI, req.Info.CapType, proto, req.FullUri);
                }
                else
                {
                    capsSession = new SessionEvent(req.RawResponse, req.ResponseHeaders, req.Info.URI, req.Info.CapType, proto);
                }

                capsSession.Columns = new string[] { PacketCounter.ToString(), capsSession.TimeStamp.ToString("HH:mm:ss.fff"), capsSession.Protocol, capsSession.Name, capsSession.Length.ToString(), capsSession.Host, capsSession.ContentType };
                messages.AddSession(capsSession);

            }
        });
    }
Ejemplo n.º 2
0
        public static Session FromOSD(OSDMap map)
        {
            Session session;

            switch (map["SessionType"].AsString())
            {
                case "SessionCaps":
                    session = new SessionCaps();
                    break;
                case "SessionEvent":
                    session = new SessionEvent();
                    break;
                case "SessionLogin":
                    session = new SessionLogin();
                    break;
                case "SessionPacket":
                    session = new SessionPacket();
                    break;
                default:
                    return null;
            }

            session.Deserialize(map);
            return session;
        }