Beispiel #1
0
        private void InterceptIncoming()
        {
            HMessage packet = Remote.ReceivePacket();

            if (packet != null)
            {
                var args = new DataInterceptedEventArgs(packet, ++_inSteps, false);
                try { OnDataIncoming(args); }
                catch { args.Restore(); }

                if (!args.IsBlocked && !args.WasRelayed)
                {
                    SendToClient(args.Packet);
                }
                if (!args.HasContinued)
                {
                    Task.Factory.StartNew(InterceptIncoming);
                }
            }
            else
            {
                Disconnect();
            }
        }
Beispiel #2
0
        private void InterceptOutgoing()
        {
            HMessage packet = Local.ReceivePacket();

            if (packet != null)
            {
                var args = new DataInterceptedEventArgs(packet, ++_outSteps, true);
                try { OnDataOutgoing(args); }
                catch { args.Restore(); }

                if (!args.IsBlocked && !args.WasRelayed)
                {
                    SendToServer(args.Packet);
                }
                if (!args.HasContinued)
                {
                    Task.Factory.StartNew(InterceptOutgoing);
                }
            }
            else
            {
                Disconnect();
            }
        }