コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xO02O">username</param>
        /// <param name="x7c37">steamID???</param>
        public static byte[] Handle(string xO02O, string x7c37)
        {
            //for now, we can ignore x7c37? assuming it is to do with verifying with steam; which we don't actually care about.

            //create a new client to represent this user.
            achronClient client = new achronClient();

            client.username  = xO02O;
            client.firstSeen = consts.GetTime();
            client.lastSeen  = client.firstSeen;

            //generate a session ID
            using (SHA256 sha256Hash = SHA256.Create())
            {
                string hash = GetHash(sha256Hash, client.username + client.firstSeen).Substring(0, 32);
                client.SESSID = hash;
            }

            string content =
                client.SESSID + @"\\" +                //SessID / unique ID
                client.username +                      //username
                "5e1355173f1786." + consts.GetTime() + //no idea what this is about
                @"\\1.7.0.0";                          //the client version

            consts.clientList.Add(client.SESSID, client);

            string reply =
                "HTTP/1.1 200 OK" + "\r\n" +                                                               //OK, we have a valid time
                "Date: Now" + "\r\n" +                                                                     //current datetime
                "Server: AchronWeb/0.0.1 (DocileDanny)" + "\r\n" +                                         //server info
                "X-Powered-By: C#/" + Environment.Version.ToString() + "\r\n" +                            //php info
                "Set-Cookie: PHPSESSID=" + client.SESSID + "; path=/" + "\r\n" +                           //set the sessid cookie
                "Expires: Thu, 19 Nov 1981 08:52:00 GMT" + "\r\n" +                                        //when the cookie expires
                "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0" + "\r\n" + //various info about caching.
                "Pragma: no-cache" + "\r\n" +                                                              //pragma values
                "Content-Length: " + content.Length.ToString() + "\r\n" +                                  //how long is the content
                "Content-Type: text/plain; charset=UTF-8" + "\r\n" + "\r\n" +                              //what is the content
                content + "\r\n";                                                                          //the content itself.

            return(UTF8Encoding.UTF8.GetBytes(reply));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xO02O">username</param>
        /// <param name="x7c37">steamID???</param>
        public static byte[] Handle(string OxO181, string OxO2O1, string OxO21O, string OxO39O, string OxO04O, string endPoint)
        {
            //client creating a new game.
            //OxO181 is the clients internal IP address
            //OxO2O1 is the games name.
            //OxO21O no idea just now; it's 0 in my test case; maybe saying if the game is in progress? not sure.
            //OxO39O this is the current level.
            //xO040 is the UID in this case
            //endPoint is the external IP for this client.

            string val            = OxO04O;
            int    maxplayerCount = 8;

            if (val.Contains("6bb3171"))
            {
                //6bb317108429 06
                int    pCountIndex     = val.IndexOf("6bb3171");
                string sMaxPlayerCount = val.Substring(pCountIndex + 12, 2);

                if (Int32.TryParse(sMaxPlayerCount, out int c))
                {
                    maxplayerCount = Int32.Parse(sMaxPlayerCount);
                }
            }

            //get the user who is trying to create the game
            achronClient user = consts.getUser(OxO04O);

            if (user == null)
            {
                return(new byte[0]);
            }

            //create a new game
            achronGame game = new achronGame();

            game.currentPlayers = new System.Collections.ArrayList();
            game.currentPlayers.Add(user.username);
            game.maxPlayers     = maxplayerCount;
            game.gamePlayerHost = user.username;
            game.portA          = 7014; //default, maybe the client will update this later?
            game.portB          = 7013; //default, maybe the client will update this later?
            game.gameName       = OxO2O1;
            game.host           = endPoint;
            game.lastUpdate     = consts.GetTime();
            game.level          = OxO39O.Replace("%20", " ");
            game.Progress       = 0; //lets assume if we are creating a game, the game is yet to start.
            game.ownerSESSID    = user.SESSID;

            lock (consts.gameList)
            {
                consts.gameCount++;
                game.gameID = consts.gameCount;
                consts.gameList.Add(game.gameID, game);
            }



            string content = game.gameID.ToString(); //tell the client the ID of the game they created.

            string reply =
                "HTTP/1.1 200 OK" + "\r\n" +                                    //OK, we have a valid time
                "Date: Now" + "\r\n" +                                          //current datetime
                "Server: AchronWeb/0.0.1 (DocileDanny)" + "\r\n" +              //server info
                "X-Powered-By: C#/" + Environment.Version.ToString() + "\r\n" + //php info
                //"Set-Cookie: PHPSESSID=" + client.SESSID + "; path=/" + "\r\n" + //set the sessid cookie
                //"Expires: Thu, 19 Nov 1981 08:52:00 GMT" + "\r\n" + //when the cookie expires
                "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0" + "\r\n" + //various info about caching.
                "Pragma: no-cache" + "\r\n" +                                                              //pragma values
                "Content-Length: " + content.Length.ToString() + "\r\n" +                                  //how long is the content
                "Content-Type: text/plain; charset=UTF-8" + "\r\n" + "\r\n" +                              //what is the content
                content + " " + "\r\n";                                                                    //the content itself.

            return(UTF8Encoding.UTF8.GetBytes(reply));
        }