コード例 #1
0
        static void ListerUser()
        {
            cRequest allo = new cRequest();

            foreach (var u in allo.getEntities().CompteJoueur)
            {
                Console.WriteLine(u.Id + ": " + u.NomUtilisateur);
            }
        }
コード例 #2
0
 /// <summary>
 /// Register an request class for packetprocessing
 /// </summary>
 /// <param name="RequestHandler">An initialized request class.</param>
 /// <param name="portal">The portal.</param>
 /// <param name="ContainerID">The container ID.</param>
 public void RegisterRequest(cRequest RequestHandler, Portal portal, ushort ContainerID)
 {
     if (Active)
     {
         throw new Exception("this PortalCollection is in use! please register portals before using");
     }
     RequestHandler._Portal     = portal;
     RequestHandler.ContainerID = ContainerID;
     portal.RegisterRequest(ContainerID, RequestHandler);
 }
コード例 #3
0
        public void loop()
        {
            TcpListener oListener = new TcpListener(port);
            TcpClient   oClient   = new TcpClient();

            oListener.Start();
            Console.WriteLine("Listening on" + host + " " + port);

            while (true)
            {
                oClient = oListener.AcceptTcpClient();
                Stream       stream    = new BufferedStream(oClient.GetStream());
                StreamWriter resStream = new StreamWriter(oClient.GetStream());
                cRequest     req       = new cRequest(stream);


                req._printVerb();
                req._printUrl();
                req._printAuth();

                if (req.bWantFile() == true)
                {
                    Console.WriteLine("Fetching the file manager...");

                    if (req._fileManager() == "image")
                    {
                    }
                    else if (req._fileManager() == "secret")
                    {
                    }
                    else
                    {
                        resStream.Write("HTTP/1.0 401 Unauthorized");
                        resStream.Write(Environment.NewLine);
                        resStream.Write(Environment.NewLine);

                        resStream.Write("ERROR 401: The request requires valid user authentication.");
                    }
                }
                else
                {
                    resStream.Write("HTTP/1.0 404 Not Found");
                    resStream.Write(Environment.NewLine);
                    resStream.Write(Environment.NewLine);

                    resStream.Write("ERROR 404: The server has not found anything matching the Request-URL.");
                }

                oClient.Close();
            }
        }