예제 #1
0
        public void NoConnectionMessage()
        {
            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var mockByteClient = new Mock <IClient <byte, byte> > ();

            mockByteClient.Setup(x => x.Stream).Returns(stream);
            var byteClient = mockByteClient.Object;

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse(eventArgs.Request.ShouldAllow);
            Assert.IsFalse(eventArgs.Request.ShouldDeny);

            Assert.AreEqual(responseStream.ToArray().Length, 0);
        }
예제 #2
0
        public void InvalidConnectionMessageIdentifier()
        {
            var connectionMessage = TestingTools.CreateConnectionRequest(Type.Stream, "123456".ToBytes());

            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(connectionMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var mockByteClient = new Mock <IClient <byte, byte> > ();

            mockByteClient.Setup(x => x.Stream).Returns(stream);
            var byteClient = mockByteClient.Object;

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse(eventArgs.Request.ShouldAllow);
            Assert.IsTrue(eventArgs.Request.ShouldDeny);

            TestingTools.CheckConnectionResponse(responseStream.ToArray(), 40, Status.MalformedMessage, "Client identifier must be 16 bytes.", 0);
        }
예제 #3
0
        public void ShortHelloMessageHeader()
        {
            var shortHelloMessage = new byte[5];

            Array.Copy(helloMessage, shortHelloMessage, shortHelloMessage.Length);

            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(shortHelloMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var mockByteClient = new Mock <IClient <byte, byte> > ();

            mockByteClient.Setup(x => x.Stream).Returns(stream);
            var byteClient = mockByteClient.Object;

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse(eventArgs.Request.ShouldAllow);
            Assert.IsTrue(eventArgs.Request.ShouldDeny);

            Assert.AreEqual(0, responseStream.Length);
        }
예제 #4
0
        public void NoHelloMessage()
        {
            var responseStream = new MemoryStream ();
            var stream = new TestStream (new MemoryStream (), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock<IServer<byte,byte>> ();
            var byteServer = mockByteServer.Object;
            var mockByteClient = new Mock<IClient<byte,byte>> ();
            mockByteClient.Setup (x => x.Stream).Returns (stream);
            var byteClient = mockByteClient.Object;

            var server = new StreamServer (byteServer);
            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow ();
            server.Start ();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionArgs<byte,byte> (byteClient);
            mockByteServer.Raise (m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse (eventArgs.Request.ShouldAllow);
            Assert.IsTrue (eventArgs.Request.ShouldDeny);

            Assert.AreEqual (0, responseStream.Length);
        }
예제 #5
0
        public void ValidHelloMessage()
        {
            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(helloMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var byteClient     = new TestClient(stream);

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsTrue(eventArgs.Request.ShouldAllow);
            Assert.IsFalse(eventArgs.Request.ShouldDeny);

            server.Update();
            Assert.AreEqual(1, server.Clients.Count());
            Assert.AreEqual(clientGuid, server.Clients.First().Guid);

            byte[] bytes         = responseStream.ToArray();
            byte[] expectedBytes = { 0x4F, 0x4B };
            Assert.IsTrue(expectedBytes.SequenceEqual(bytes));
        }
예제 #6
0
        public void WrongConnectionType()
        {
            var responseStream = new MemoryStream();

            var connectionMessage = TestingTools.CreateConnectionRequest(Type.Rpc, clientId.ToByteArray());
            var stream            = new TestStream(new MemoryStream(connectionMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var mockByteClient = new Mock <IClient <byte, byte> > ();

            mockByteClient.Setup(x => x.Stream).Returns(stream);
            var byteClient = mockByteClient.Object;

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse(eventArgs.Request.ShouldAllow);
            Assert.IsTrue(eventArgs.Request.ShouldDeny);

            TestingTools.CheckConnectionResponse(responseStream.ToArray(), 120, Status.WrongType,
                                                 "Connection request was for the rpc server, but this is the stream server. " +
                                                 "Did you connect to the wrong port number?", 0);
        }
예제 #7
0
        public void ValidConnectionMessage()
        {
            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(TestingTools.CreateConnectionRequest(Type.Stream, clientId.ToByteArray())), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var byteClient     = new TestClient(stream);

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsTrue(eventArgs.Request.ShouldAllow);
            Assert.IsFalse(eventArgs.Request.ShouldDeny);

            server.Update();
            Assert.AreEqual(1, server.Clients.Count());
            Assert.AreEqual(clientId, server.Clients.First().Guid);

            TestingTools.CheckConnectionResponse(responseStream.ToArray(), 19, Status.Ok, string.Empty, 16);
        }
 void GameConnection_DisconnectedEvent(object sender, EventArgs e)
 {
     Logger.Trace("Client IP: {0} disconnected", m_CurrentInfo != null ? m_CurrentInfo.Id.ToString() : this.ToString());
     Dispose();
     //StreamServerController.DisconnecteStreamServer(m_CurrentInfo != null ? m_CurrentInfo.Id : this.CurrentInfo.Id);
     m_CurrentInfo = null;
     //Offline the game server's status
 }
        private async Task ConnectAsync(StreamServer ss)
        {
            await WebSocketClient
            .ConnectAsync(new System.Uri(
                              $"wss://{ss.Fmp4.Host}/ws.app/stream/{ss.Movie.Id}/fmp4/bd/1/1500?mode=source"))
            .ConfigureAwait(false);

            IsRecording = true;
        }
예제 #10
0
        internal KRPCServer(IPAddress address, ushort rpcPort, ushort streamPort,
                             bool oneRPCPerUpdate = false, uint maxTimePerUpdate = 5000, bool adaptiveRateControl = true, bool blockingRecv = true, uint recvTimeout = 1000)
        {
            rpcTcpServer = new TCPServer ("RPCServer", address, rpcPort);
            streamTcpServer = new TCPServer ("StreamServer", address, streamPort);
            rpcServer = new RPCServer (rpcTcpServer);
            streamServer = new StreamServer (streamTcpServer);
            clientScheduler = new RoundRobinScheduler<IClient<Request,Response>> ();
            continuations = new List<RequestContinuation> ();
            streamRequests = new Dictionary<IClient<byte,StreamMessage>,IList<StreamRequest>> ();

            OneRPCPerUpdate = oneRPCPerUpdate;
            MaxTimePerUpdate = maxTimePerUpdate;
            AdaptiveRateControl = adaptiveRateControl;
            BlockingRecv = blockingRecv;
            RecvTimeout = recvTimeout;

            // Tie events to underlying server
            rpcServer.OnStarted += (s, e) => {
                if (OnStarted != null)
                    OnStarted (this, EventArgs.Empty);
            };
            rpcServer.OnStopped += (s, e) => {
                if (OnStopped != null)
                    OnStopped (this, EventArgs.Empty);
            };
            rpcServer.OnClientRequestingConnection += (s, e) => {
                if (OnClientRequestingConnection != null)
                    OnClientRequestingConnection (s, e);
            };
            rpcServer.OnClientConnected += (s, e) => {
                if (OnClientConnected != null)
                    OnClientConnected (s, e);
            };
            rpcServer.OnClientDisconnected += (s, e) => {
                if (OnClientDisconnected != null)
                    OnClientDisconnected (s, e);
            };

            // Add/remove clients from the scheduler
            rpcServer.OnClientConnected += (s, e) => clientScheduler.Add (e.Client);
            rpcServer.OnClientDisconnected += (s, e) => clientScheduler.Remove (e.Client);

            // Add/remove clients from the list of stream requests
            streamServer.OnClientConnected += (s, e) => streamRequests [e.Client] = new List<StreamRequest> ();
            streamServer.OnClientDisconnected += (s, e) => streamRequests.Remove (e.Client);

            // Validate stream client identifiers
            streamServer.OnClientRequestingConnection += (s, e) => {
                if (rpcServer.Clients.Where (c => c.Guid == e.Client.Guid).Any ())
                    e.Request.Allow ();
                else
                    e.Request.Deny ();
            };
        }
예제 #11
0
파일: Program.cs 프로젝트: gaetanV/csharp
        static void Main(string[] args)
        {
            WebServer     ws = new WebServer("http://*:8080/");
            GitController c  = new GitController();

            ws.Add(c);
            StreamServer d = new StreamServer();

            while (true)
            {
            }
        }
예제 #12
0
        public void ValidConnectionRequest()
        {
            var clientGuid       = new Guid("1234567890abcdef1234567890abcdef".ToBytes());
            var clientGuidBase64 = Convert.ToBase64String(clientGuid.ToByteArray());
            var request          = Encoding.ASCII.GetBytes(
                "GET /?id=" + clientGuidBase64 + " HTTP/1.1\r\n" +
                "Host: localhost\r\n" +
                "Upgrade: websocket\r\n" +
                "Connection: Upgrade\r\n" +
                "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" +
                "Sec-WebSocket-Version: 13\r\n\r\n"
                );

            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(request), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var byteClient     = new TestClient(stream);

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsTrue(eventArgs.Request.ShouldAllow);
            Assert.IsFalse(eventArgs.Request.ShouldDeny);

            server.Update();
            Assert.AreEqual(1, server.Clients.Count());
            Assert.AreEqual(clientGuid, server.Clients.First().Guid);

            var response = Encoding.ASCII.GetString(responseStream.ToArray());

            Assert.AreEqual(
                "HTTP/1.1 101 Switching Protocols\r\n" +
                "Upgrade: websocket\r\n" +
                "Connection: Upgrade\r\n" +
                "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n",
                response
                );
        }
예제 #13
0
파일: KRPCServer.cs 프로젝트: 602p/krpc
        internal KRPCServer(IPAddress address, ushort rpcPort, ushort streamPort)
        {
            rpcTcpServer = new TCPServer ("RPCServer", address, rpcPort);
            streamTcpServer = new TCPServer ("StreamServer", address, streamPort);
            rpcServer = new RPCServer (rpcTcpServer);
            streamServer = new StreamServer (streamTcpServer);
            clientScheduler = new RoundRobinScheduler<IClient<Request,Response>> ();
            continuations = new List<RequestContinuation> ();
            streamRequests = new Dictionary<IClient<byte,StreamMessage>,IList<StreamRequest>> ();

            // Tie events to underlying server
            rpcServer.OnStarted += (s, e) => {
                if (OnStarted != null)
                    OnStarted (this, EventArgs.Empty);
            };
            rpcServer.OnStopped += (s, e) => {
                if (OnStopped != null)
                    OnStopped (this, EventArgs.Empty);
            };
            rpcServer.OnClientRequestingConnection += (s, e) => {
                if (OnClientRequestingConnection != null)
                    OnClientRequestingConnection (s, e);
            };
            rpcServer.OnClientConnected += (s, e) => {
                if (OnClientConnected != null)
                    OnClientConnected (s, e);
            };
            rpcServer.OnClientDisconnected += (s, e) => {
                if (OnClientDisconnected != null)
                    OnClientDisconnected (s, e);
            };

            // Add/remove clients from the scheduler
            rpcServer.OnClientConnected += (s, e) => clientScheduler.Add (e.Client);
            rpcServer.OnClientDisconnected += (s, e) => clientScheduler.Remove (e.Client);

            // Add/remove clients from the list of stream requests
            streamServer.OnClientConnected += (s, e) => streamRequests [e.Client] = new List<StreamRequest> ();
            streamServer.OnClientDisconnected += (s, e) => streamRequests.Remove (e.Client);

            // Validate stream client identifiers
            streamServer.OnClientRequestingConnection += (s, e) => {
                if (rpcServer.Clients.Where (c => c.Guid == e.Client.Guid).Any ())
                    e.Request.Allow ();
                else
                    e.Request.Deny ();
            };
        }
예제 #14
0
        public bool CreateRoom(string room_name)
        {
            string groupName;
            int    newport;

            if (RoomSet.Contains(room_name))
            {
                return(false);
            }
            RoomSet.Add(room_name);
            while (true)
            {
                groupName = RandomString(12);
                if (!GroupSet.Contains(groupName))
                {
                    break;
                }
            }
            sessions[room_name] = groupName;
            Console.WriteLine(groupName);
            GroupSet.Add(groupName);
            while (true)
            {
                newport = random.Next(1000, 65000);
                if (!PortSet.Contains(newport) && !PortInUse(newport))
                {
                    break;
                }
            }
            PortSet.Add(newport);
            ports.Add(groupName, newport);
            try
            {
                LastScreen.Add(groupName, new Part[10, 10]);
                messages.Add(groupName, new List <Message>());
            }
            catch { }
            StreamServer streamServer = new StreamServer(newport);

            servers.Add(groupName, streamServer);
            streamServer.Init();
            streamServer.ConnectToServer();
            return(true);
        }
예제 #15
0
        public void InvalidConnectionRequestNoGuid()
        {
            var ascii   = Encoding.ASCII;
            var request = ascii.GetBytes(
                "GET / HTTP/1.1\r\n" +
                "Host: localhost\r\n" +
                "Upgrade: websocket\r\n" +
                "Connection: Upgrade\r\n" +
                "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n" +
                "Sec-WebSocket-Version: 13\r\n\r\n"
                );

            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(request), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var byteClient     = new TestClient(stream);

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse(eventArgs.Request.ShouldAllow);
            Assert.IsTrue(eventArgs.Request.ShouldDeny);

            server.Update();
            Assert.AreEqual(0, server.Clients.Count());

            var response = ascii.GetString(responseStream.ToArray());

            Assert.AreEqual(
                "HTTP/1.1 400 Bad Request\r\n\r\n",
                response
                );
        }
예제 #16
0
        public void InvalidConnectionMessageHeader()
        {
            var connectionMessage = TestingTools.CreateConnectionRequest(Type.Stream, clientId.ToByteArray());

            connectionMessage [2] ^= 0x42;
            connectionMessage [3] ^= 0x42;
            connectionMessage [4] ^= 0x42;
            connectionMessage [5] ^= 0x42;

            var responseStream = new MemoryStream();
            var stream         = new TestStream(new MemoryStream(connectionMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock <IServer <byte, byte> > ();
            var byteServer     = mockByteServer.Object;
            var mockByteClient = new Mock <IClient <byte, byte> > ();

            mockByteClient.Setup(x => x.Stream).Returns(stream);
            var byteClient = mockByteClient.Object;

            var server = new StreamServer(byteServer);

            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow();
            server.Start();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionEventArgs <byte, byte> (byteClient);

            mockByteServer.Raise(m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsFalse(eventArgs.Request.ShouldAllow);
            Assert.IsTrue(eventArgs.Request.ShouldDeny);

            TestingTools.CheckConnectionResponse(responseStream.ToArray(), 209, Status.MalformedMessage,
                                                 "While parsing a protocol message, the input ended unexpectedly in the middle of a field.  " +
                                                 "This could mean either that the input has been truncated or that an embedded message misreported its own length.", 0);
        }
예제 #17
0
 /// <summary>
 /// Clear the server statistics.
 /// </summary>
 public void ClearStats()
 {
     RPCServer.ClearStats();
     StreamServer.ClearStats();
 }
예제 #18
0
 public DebuggerServer() : base(UDP_SERVER_PORT)
 {
     audioStreamer  = new StreamServer(this, OP_AUDIO_DATA);
     screenStreamer = new StreamServer(this, OP_SCREENCAP_DATA);
 }
예제 #19
0
 public override void Run()
 {
     Logger.Info("GameServer Run! listening hostIP:{0}, port:{1}", ConfData.HostIp, ConfData.HostPort);
     serverImp = new StreamServer(this, ConfData.HostIp, Convert.ToInt32(ConfData.HostPort));
     serverImp.Run();
 }
예제 #20
0
        public void ValidHelloMessage()
        {
            var responseStream = new MemoryStream ();
            var stream = new TestStream (new MemoryStream (helloMessage), responseStream);

            // Create mock byte server and client
            var mockByteServer = new Mock<IServer<byte,byte>> ();
            var byteServer = mockByteServer.Object;
            var byteClient = new TestClient (stream);

            var server = new StreamServer (byteServer);
            server.OnClientRequestingConnection += (sender, e) => e.Request.Allow ();
            server.Start ();

            // Fire a client connection event
            var eventArgs = new ClientRequestingConnectionArgs<byte,byte> (byteClient);
            mockByteServer.Raise (m => m.OnClientRequestingConnection += null, eventArgs);

            Assert.IsTrue (eventArgs.Request.ShouldAllow);
            Assert.IsFalse (eventArgs.Request.ShouldDeny);

            server.Update ();
            Assert.AreEqual (1, server.Clients.Count ());
            Assert.AreEqual (clientGuid, server.Clients.First ().Guid);

            byte[] bytes = responseStream.ToArray ();
            byte[] expectedBytes = { 0x4F, 0x4B };
            Assert.IsTrue (expectedBytes.SequenceEqual (bytes));
        }
예제 #21
0
파일: KRPCServer.cs 프로젝트: pipi1226/krpc
        internal KRPCServer(IPAddress address, ushort rpcPort, ushort streamPort,
                            bool oneRPCPerUpdate     = false, uint maxTimePerUpdate = 5000,
                            bool adaptiveRateControl = true, bool blockingRecv      = true, uint recvTimeout = 1000)
        {
            rpcTcpServer    = new TCPServer("RPCServer", address, rpcPort);
            streamTcpServer = new TCPServer("StreamServer", address, streamPort);
            rpcServer       = new RPCServer(rpcTcpServer);
            streamServer    = new StreamServer(streamTcpServer);
            clientScheduler = new RoundRobinScheduler <IClient <Request, Response> > ();
            continuations   = new List <RequestContinuation> ();
            streamRequests  = new Dictionary <IClient <byte, StreamMessage>, IList <StreamRequest> > ();

            OneRPCPerUpdate     = oneRPCPerUpdate;
            MaxTimePerUpdate    = maxTimePerUpdate;
            AdaptiveRateControl = adaptiveRateControl;
            BlockingRecv        = blockingRecv;
            RecvTimeout         = recvTimeout;

            // Tie events to underlying server
            rpcServer.OnStarted += (s, e) => {
                if (OnStarted != null)
                {
                    OnStarted(this, EventArgs.Empty);
                }
            };
            rpcServer.OnStopped += (s, e) => {
                if (OnStopped != null)
                {
                    OnStopped(this, EventArgs.Empty);
                }
            };
            rpcServer.OnClientRequestingConnection += (s, e) => {
                if (OnClientRequestingConnection != null)
                {
                    OnClientRequestingConnection(s, e);
                }
            };
            rpcServer.OnClientConnected += (s, e) => {
                if (OnClientConnected != null)
                {
                    OnClientConnected(s, e);
                }
            };
            rpcServer.OnClientDisconnected += (s, e) => {
                if (OnClientDisconnected != null)
                {
                    OnClientDisconnected(s, e);
                }
            };

            // Add/remove clients from the scheduler
            rpcServer.OnClientConnected    += (s, e) => clientScheduler.Add(e.Client);
            rpcServer.OnClientDisconnected += (s, e) => clientScheduler.Remove(e.Client);

            // Add/remove clients from the list of stream requests
            streamServer.OnClientConnected    += (s, e) => streamRequests [e.Client] = new List <StreamRequest> ();
            streamServer.OnClientDisconnected += (s, e) => streamRequests.Remove(e.Client);

            // Validate stream client identifiers
            streamServer.OnClientRequestingConnection += (s, e) => {
                if (rpcServer.Clients.Where(c => c.Guid == e.Client.Guid).Any())
                {
                    e.Request.Allow();
                }
                else
                {
                    e.Request.Deny();
                }
            };
        }