Exemplo n.º 1
0
        /*
         * Waits for the Battling Users to send the next request
         *
         * @params:
         *      - BH: The BattleHandler
         */
        public void Rewait(BattleHandler BH)
        {
            client1 = null;
            client2 = null;

            while (client1 == null || client2 == null)
            {
                if (client1 == null)
                {
                    client1 = Server.AcceptSocket();
                    string username;
                    if (AuthorizeAgain(client1, ref BH, out username) == 0)
                    {
                        SendHead(200, "text/plain", 300, ref client1);
                        SendBody("Authorized for Battle!\n", ref client1);
                        BH.RC = RC;
                        BH.DoRequest(ref client1, username);
                    }
                    else
                    {
                        SendResponse(200, "text/plain", "Not Authorized for Battle!", ref client1);
                        client1.Close();
                    }
                }

                if (client2 == null)
                {
                    client2 = Server.AcceptSocket();
                    string username;
                    if (AuthorizeAgain(client2, ref BH, out username) == 0)
                    {
                        //BuildContext(ReceiveRequest(ref client));
                        SendHead(200, "text/plain", 300, ref client2);
                        SendBody("Authorized for Battle!\n", ref client2);
                        BH.RC = RC;
                        BH.DoRequest(ref client2, username);
                    }
                    else
                    {
                        SendResponse(200, "text/plain", "Not Authorized for Battle!", ref client2);
                        client2.Close();
                    }
                }
            }
        }