Beispiel #1
0
        public static void Main()
        {
            SakeAppProgram sakeapp = new SakeAppProgram();

            sakeapp.Run();

            AtlasAppProgram atlasapp = new AtlasAppProgram();

            atlasapp.Run();

            NatAppProgram natnegapp = new NatAppProgram();
            //natnegapp.Run();  // This requires 2 applications running simultenously.

            QR2AppProgram qr2app = new QR2AppProgram();

            qr2app.Run();

            ServerBrowserAppProgram serverBrowserApp = new ServerBrowserAppProgram();

            serverBrowserApp.Run();
        }
        public void Run()
        {
            AtlasAppProgram atlasapp = new AtlasAppProgram();
            string          gamename = _GameName;
            SCResult        result   = SCResult.SCResult_NO_ERROR;

            Console.WriteLine("\n------------ Atlas C# Sample --------------------------");

            if (atlasapp.CheckServices(gamename) != GSIACResult.GSIACAvailable)
            {
                Console.WriteLine("{0}: Online services are unavailable now.\n", gamename);
                return;
            }

#if GSI_COMMON_DEBUG
            gamespyCommonDebug.gsOpenDebugFile("Debug_Atlas.log");
            gamespyCommonDebug.gsSetDebugLevel(GSIDebugCategory.GSIDebugCat_All, GSIDebugType.GSIDebugType_All, GSIDebugLevel.Hardcore);
#endif
            if (Initialize())
            {
                Console.WriteLine("{0}: Initialized.\n", gamename);
            }
            else
            {
                Console.WriteLine("{0}: Failed initialize.\n", gamename);
                Terminate();
                Console.WriteLine("------------ Atlas C# Sample Terminated------------------------\n");
                Console.WriteLine("Press AnyKey Continue....");
                Console.ReadLine();

                return;
            }

            // scCreateSession example
            gamespyAtlas.SCCreateSessionCallback createSessionCallback = new gamespyAtlas.SCCreateSessionCallback(competitionCreateSessionCallback);

            Console.WriteLine("\nAtlas : Create Session\n");
            result = gamespyAtlas.scCreateSession(atlasInterface, ref gameCertificate, ref gamePrivateData, createSessionCallback, 0, IntPtr.Zero);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Create Session : {0}\n", result);
                return;
            }

            WaitForResponse(atlasInterface);
            Console.WriteLine("Create Session completed. \n");

            gamespyAtlas.SCSetReportIntentionCallback setReportIntentionCallback = new gamespyAtlas.SCSetReportIntentionCallback(competitionSetReportIntentionCallback);
            respReceived = false;
            Console.WriteLine("Set Report Intention\n");
            result = gamespyAtlas.scSetReportIntention(atlasInterface, null, true, ref gameCertificate, ref gamePrivateData, setReportIntentionCallback, 0, IntPtr.Zero);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Set Report Intention : {0}\n", result);
                return;
            }

            while (respReceived == false)
            {
                gamespyAtlas.scThink(atlasInterface);
                if (respReceived == false)
                {
                    Thread.Sleep(new TimeSpan(100000));
                }
            }
            Console.WriteLine("Set Report Intention completed. \n");

            Console.WriteLine("Create Report");
            result = gamespyAtlas.scCreateReport(atlasInterface, _AtlasRuleSetVersion, 1, 0, ref atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Create Report : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Report Created succesfully!\n");
            }

            Console.WriteLine("Create Report completed. \n");

            //  Begin the game's (global data) section of the report
            result = gamespyAtlas.scReportBeginGlobalData(atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Report Begin Global Data : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Report Begin Global Data completed succesfully!\n");
            }

            // add the game-level key values

            AtlasKeyList gameKeys = new AtlasKeyList();
            initGameKeys(gameKeys);
            result = gameKeys.generateReport(atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Generate Report : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Generate Report completed Succesfully!\n");
            }

            result = gamespyAtlas.scReportBeginPlayerData(atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Report Begin Player Data : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Report Begin Player Data completed succesfully!\n");
            }

            // This is the start of a new player
            result = gamespyAtlas.scReportBeginNewPlayer(atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Report Begin New Player Data : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Report Begin New Player Data completed succesfully!\n");
            }
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            byte[] connectionId = encoding.GetBytes(Marshal.PtrToStringAnsi(gamespyAtlas.scGetConnectionId(atlasInterface)));
            result = gamespyAtlas.scReportSetPlayerData
                     (
                atlasReport,
                0,
                connectionId,
                0,
                SCGameResult.SCGameResult_WIN,
                gameCertificate.mProfileId,
                ref gameCertificate,
                null
                     );
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Set Player Data : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Set Player Data completed succesfully!\n");
            }

            AtlasKeyList playerKeys = new AtlasKeyList();
            initPlayerKeys(playerKeys);
            result = playerKeys.generateReport(atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Generate Report : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Generate Report completed succesfully!\n");
            }

            result = gamespyAtlas.scReportBeginTeamData(atlasReport);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Begin Team Data : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Begin Team Data completed succesfully!\n");
            }

            result = gamespyAtlas.scReportEnd(atlasReport, true, SCGameStatus.SCGameStatus_COMPLETE);
            if (result != SCResult.SCResult_NO_ERROR)
            {
                Console.WriteLine("Error in Report End : {0}\n", result);
                return;
            }
            else
            {
                Console.WriteLine("Atlas Report End completed succesfully!\n");
            }
            gamespyAtlas.SCSubmitReportCallback submitReportcallback = new gamespyAtlas.SCSubmitReportCallback(competitionSubmitReportCallback);
            Console.WriteLine("\nAtlas : Set Report Intention\n");
            Console.WriteLine("Submitting a report for the ATLAS session...\n");
            result = gamespyAtlas.scSubmitReport(atlasInterface, atlasReport, true, ref gameCertificate,
                                                 ref gamePrivateData, submitReportcallback, 0, IntPtr.Zero);

            WaitForResponse(atlasInterface);

            Terminate();
            Console.WriteLine("\n------------ Atlas C# Sample Completed------------------------\n");
            Console.WriteLine("Press Enter Continue....");
            Console.ReadLine();
        }