Beispiel #1
0
        protected virtual bool HandleOutgoing(HMessage current, HMessage previous)
        {
            if (current.Length == 6)
            {
                // Range: 6
                if (TryHandleAvatarMenuClick(current, previous))
                {
                    return(true);
                }
                if (TryHandleHostExitRoom(current, previous))
                {
                    return(true);
                }
            }
            else if (current.Length >= 36 && current.Length <= 50)
            {
                //Range: 36 - 50
                if (TryHandleHostRaiseSign(current, previous))
                {
                    return(true);
                }
                if (TryHandleHostNavigateRoom(current, previous))
                {
                    return(true);
                }
            }

            return(OutDetected.ContainsKey(current.Header) ||
                   OutDetected.ContainsKey(previous.Header));
        }
Beispiel #2
0
        public void HandleOutgoing(InterceptedEventArgs e)
        {
            bool ignoreCurrent = true;

            try
            {
                e.Packet.Position = 0;
                if (_outAttaches.ContainsKey(e.Packet.Header))
                {
                    _outAttaches[e.Packet.Header](e);
                }

                if (DetectOutgoing)
                {
                    e.Packet.Position = 0;
                    HMessage previous = _outPrevious.Count > 0 ?
                                        _outPrevious.Pop() : e.Packet;

                    bool currentDetected  = OutDetected.ContainsKey(e.Packet.Header);
                    bool previousDetected = OutDetected.ContainsKey(previous.Header);

                    if (!currentDetected && !previousDetected)
                    {
                        ignoreCurrent = HandleOutgoing(e.Packet, previous);
                    }

                    if (ignoreCurrent)
                    {
                        e.Packet.Position     =
                            previous.Position = 0;

                        if (OutDetected.ContainsKey(e.Packet.Header))
                        {
                            OutDetected[e.Packet.Header](e);
                        }
                        else if (OutDetected.ContainsKey(previous.Header) && !previousDetected)
                        {
                            var args = new InterceptedEventArgs(null, e.Step - 1, previous);
                            OutDetected[previous.Header](args);
                        }
                    }
                }
            }
            finally
            {
                e.Packet.Position = 0;

                if (DetectOutgoing)
                {
                    _outPrevious.Push(e.Packet);
                }
            }
        }