// Matched And 10KB Chat Test
        public void StartTest(bool bAutoClick, int ClickIndex)
        {
            string PreFixUserID = MainWindow.Instance.PreFixUserID.Text.Trim();

            if (string.IsNullOrEmpty(PreFixUserID))
            {
                MessageBox.Show("Enter valid PreFixUserID");
                return;
            }

            int PrefixStartID = Convert.ToInt32(MainWindow.Instance.UserBeginIdNum.Text);

            if (PrefixStartID <= 0)
            {
                MessageBox.Show("Enter valid StartID!! be Higher than Zero");
                return;
            }

            if (bAutoClick == false)
            {
                mReTryCount       = 0;
                mFailedReTryCount = 0;
            }

            if (bAutoClick == true && ClickIndex == 1)
            {
                PrintStatus(1, "ReTry PartyChat Test!!");
            }

            if (bAutoClick == true && ClickIndex == 2)
            {
                mFailedReTryCount++;
            }

            CloseAllConnections();
            InitStatusValue();

            UpdateMatchedChatTestStatueUI();

            MainWindow.Instance.textOutput3.Text = string.Empty;
            var StresssTestGameID = MainWindow.GetGameIDFromUI(MainWindow.Instance.stress_comboBoxGameID_Matced10KB);


            for (int i = 0; i < 4; i++)
            {
                StressTest_Matched_Chat TestMatchedChatUser = new StressTest_Matched_Chat();
                TestMatchedChatUser.InitEngine();
                TestMatchedChatUser.SetPrintHanlde(PrintStatus);

                TestMatchedChatUser.m_LoginID = MakeStreesTestUserID(PrefixStartID, PreFixUserID, i);

                if (i == 0)
                {
                    TestMatchedChatUser.IsPartyBoss = true;
                    mCurPartyBossName = TestMatchedChatUser.m_LoginID;

                    this.mPartyBoss = TestMatchedChatUser;
                }
                else
                {
                    TestMatchedChatUser.IsPartyBoss = false;
                }

                TestMatchedChatUser.gameID = StresssTestGameID;
                mTestMatchedChatUsers.Add(TestMatchedChatUser);
            }


            UpdateMatchedChatTestStatueUI();

            ServerAddressRegistry.SaveGameID(2, StresssTestGameID);
            NetAddress serverAddress = MainWindow.Instance.GetServerAddressFromUI(1, MainWindow.Instance.stress_comboBoxIPAddress,
                                                                                  () =>
            {
                MainWindow.InitIPAdressComboBox(MainWindow.Instance.stress_comboBoxIPAddress, ServerAddressRegistry.GetServerAddresses(1));
            });

            //mLoginCurrectConnectedUser

            for (int i = 0; i < mTestMatchedChatUsers.Count; i++)
            {
                mTestMatchedChatUsers[i].RunConnect(serverAddress,
                                                    (StressTest_Matched_Chat user) =>
                {
                    mLoginCurrectConnectedUser++;
                    UpdateMatchedChatTestStatueUI();
                },
                                                    (StressTest_Matched_Chat user, SF.Net.SendMessageLogin l) =>
                {
                    if (l != null)
                    {
                        mLoginCurrectConnectedUser--;
                    }

                    UpdateMatchedChatTestStatueUI();
                },
                                                    (StressTest_Matched_Chat user, int FailedIndex) =>
                {
                    mLoginFailedUserCount++;
                    UpdateMatchedChatTestStatueUI();
                },
                                                    (StressTest_Matched_Chat user) =>
                {
                    mPartyGameSvrCurrectConnectedUser++;
                    UpdateMatchedChatTestStatueUI();
                },
                                                    (StressTest_Matched_Chat user, SF.Net.SendMessageGame l) =>
                {
                    if (l != null)
                    {
                        mPartyGameSvrCurrectConnectedUser--;
                    }

                    UpdateMatchedChatTestStatueUI();
                },
                                                    (StressTest_Matched_Chat user) =>
                {
                    mPartyGameSvrFailedConnectUser++;
                    UpdateMatchedChatTestStatueUI();
                },

                                                    ///
                                                    (StressTest_Matched_Chat user, bool Success) =>
                {
                    if (Success)
                    {
                        mPartyGameSuccessJoinCount++;
                    }

                    UpdateMatchedChatTestStatueUI();
                },

                                                    // Party Create Res
                                                    (StressTest_Matched_Chat user) =>
                {
                    if (!user.IsPartyBoss)
                    {
                        return;
                    }

                    if (mWaitFullJoin != null)
                    {
                        MessageBox.Show("WaitFullJoin did not Stop!!");
                        return;
                    }

                    mPartyGameJoinedCount++;
                    UpdateMatchedChatTestStatueUI();

                    DateTime StartWaitTime = DateTime.Now;

                    mWaitFullJoin = new Thread(new ThreadStart(() =>
                    {
                        bool IsFullReadyJoin = false;
                        while (!IsFullReadyJoin)
                        {
                            if ((StartWaitTime - DateTime.Now).Seconds > 10)
                            {
                                PrintStatus(1, "Plz Retry Chat Test!!");
                                break;
                            }

                            if (mPartyGameSuccessJoinCount == 4)
                            {
                                int FreeUserCount = 0;
                                for (int j = 0; j < mTestMatchedChatUsers.Count; j++)
                                {
                                    if (mTestMatchedChatUsers[j].IsPartyBoss)
                                    {
                                        if (mTestMatchedChatUsers[j].CurState == StressTest_Matched_Chat.eTesterState.PARTY_MATCING)
                                        {
                                            FreeUserCount++;
                                        }
                                    }
                                    else
                                    {
                                        if (mTestMatchedChatUsers[j].CurState == StressTest_Matched_Chat.eTesterState.PARTY_WAIT_INVITE)
                                        {
                                            FreeUserCount++;
                                        }
                                    }
                                }

                                if (FreeUserCount == 4)
                                {
                                    IsFullReadyJoin = true;
                                    break;
                                }
                            }
                            Thread.Sleep(1000);
                        }

                        if (IsFullReadyJoin)    // == 4)
                        {
                            PrintStatus(1, "FullJoin!! Do it Test Invite");
                            OnTestPartyChatInvite();
                        }
                    }));

                    mWaitFullJoin.Start();
                },
                                                    // Party Joined
                                                    (StressTest_Matched_Chat user, bool success) =>
                {
                    if (success)
                    {
                        mPartyGameJoinedCount++;
                        UpdateMatchedChatTestStatueUI();

                        if (mPartyGameJoinedCount == 4)
                        {
                            //-- for..
                            for (int j = 0; j < mTestMatchedChatUsers.Count; j++)
                            {
                                if (mTestMatchedChatUsers[j].IsPartyBoss)
                                {
                                    mTestMatchedChatUsers[j].NextState = StressTest_Matched_Chat.eTesterState.SEND_CHATING;
                                }
                                else
                                {
                                    mTestMatchedChatUsers[j].NextState = StressTest_Matched_Chat.eTesterState.WAIT_RECV_CHATING;
                                }
                            }

                            // Send 1KB Chat Repeat 10
                            for (int scc = 0; scc < SendChatRepeatCount; scc++)
                            {
                                if (mPartyBoss.m_Game.PartyChatMessageCmd(0, mTestSend1KBData[scc]) == 0)
                                {
                                    mPartyOneKBChatSendCount++;

                                    mPartyChatSendTime[scc] = DateTime.Now;
                                    PrintStatus(1, "Send 1KB Chat Repeat {0} Time = {1}  / {2}", scc, mPartyChatSendTime[scc].ToString("hh/mm/ss.fff"), mPartyBoss.m_LoginID);
                                }
                            }

                            //PrintStatus(1, "Send 1KB Chat Repeat {0} Time = {1} ", SendChatRepeatCount, mPartyChatSendTime.ToString("hh/mm/ss.fff"));
                            UpdateMatchedChatTestStatueUI();
                        }
                    }
                    else
                    {
                    }
                },
                                                    (StressTest_Matched_Chat user, bool success) =>
                {
                    if (!user.IsPartyBoss)
                    {
                        return;
                    }

                    if (success)
                    {
                        mPartyOneKBChatSendSuccessCount++;
                        UpdateMatchedChatTestStatueUI();
                    }
                },
                                                    (StressTest_Matched_Chat user) =>
                {
                    mPartyChatRecevice_FinishUserCount++;

                    if (!user.IsPartyBoss)
                    {
                        // 1KB Recved 10
                        mPartyChatLAverageValue = user.GetChatRecved_AverageValue(mPartyChatSendTime[0]);
                        PrintStatus(1, "Receviced 10KB Average Speed = {0}ms / ID ={1}", mPartyChatLAverageValue, user.m_LoginID);
                        UpdateMatchedChatTestStatueUI();
                    }

                    if (mPartyChatRecevice_FinishUserCount == 4)
                    {
                        if (MainWindow.Instance.InfiniteRepeatCheck.IsChecked == true)
                        {
                            System.Threading.Tasks.Task.Delay(3000).ContinueWith(t =>
                            {
                                MainWindow.Instance.btnStressTestMatched_Cp_Chat.Dispatcher.Invoke(new UpdateButtonPress_Delegate(delegate()
                                {
                                    mReTryCount++;
                                    MainWindow.Instance.btnStressTestMatched_Cp_Chat.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                                }));
                            });
                        }
                    }
                }
                                                    );
            }

            m_MatchedChatTestTimer       = new DispatcherTimer();
            m_MatchedChatTestTimer.Tick += new EventHandler(
                (object ts, EventArgs te) =>
            {
                for (int i = 0; i < mTestMatchedChatUsers.Count; i++)
                {
                    mTestMatchedChatUsers[i].OnTimerTick(UpdateTick);
                }

                if (IsProgressFailed() && MainWindow.Instance.InfiniteReTryFailedRepeattCheck_MatchChat.IsChecked == true)
                {
                    mCurDealyReTryTime += UpdateTick;
                    if (mCurDealyReTryTime >= 1000)
                    {
                        mTickCount++;
                        mCurDealyReTryTime = 0;
                        PrintStatus(1, "Plz ReTry Test!! {0}..", 3 - mTickCount);
                        if (mTickCount == 3)
                        {
                            this.StartTest(true, 2);
                        }
                    }
                }
            });

            m_MatchedChatTestTimer.Interval = new TimeSpan(0, 0, 0, 0, UpdateTick);
            m_MatchedChatTestTimer.Start();
        }
Esempio n. 2
0
        // Matched And 10KB Chat Test
        public void StartTest(bool bAutoClick, int ClickIndex)
        {
            string PreFixUserID = MainWindow.Instance.PreFixUserID.Text.Trim();

            if (string.IsNullOrEmpty(PreFixUserID))
            {
                MessageBox.Show("Enter valid PreFixUserID");
                return;
            }

            int PrefixStartID = Convert.ToInt32(MainWindow.Instance.UserBeginIdNum.Text);

            if (PrefixStartID <= 0)
            {
                MessageBox.Show("Enter valid StartID!! be Higher than Zero");
                return;
            }

            if (bAutoClick == false)
            {
                mReTryCount       = 0;
                mFailedReTryCount = 0;
            }

            if (bAutoClick == true && ClickIndex == 1)
            {
                PrintStatus(1, "ReTry PartyChat Test!!");
            }

            if (bAutoClick == true && ClickIndex == 2)
            {
                mFailedReTryCount++;
            }

            CloseAllConnections();
            InitStatusValue();

            UpdateMatchedChatTestStatueUI();

            MainWindow.Instance.textOutput3.Text = string.Empty;
            var StresssTestGameID = MainWindow.GetGameIDFromUI(MainWindow.Instance.stress_comboBoxGameID_Matced10KB);


            for (int i = 0; i < MaxMatchedTestUserCount; i++)
            {
                StressTest_Matched_Chat TestMatchedChatUser = new StressTest_Matched_Chat();
                TestMatchedChatUser.InitEngine();
                TestMatchedChatUser.SetPrintHanlde(PrintStatus);

                TestMatchedChatUser.m_LoginID = MakeStreesTestUserID(PrefixStartID, PreFixUserID, i);

                if (i == 0)
                {
                    TestMatchedChatUser.IsPartyBoss = true;
                    mCurPartyBossName = TestMatchedChatUser.m_LoginID;

                    this.mPartyBoss = TestMatchedChatUser;

                    TestMatchedChatUser.IsPutRecvChatLog = bPutBossChatLog;
                }
                else
                {
                    TestMatchedChatUser.IsPartyBoss = false;
                }

                TestMatchedChatUser.gameID = StresssTestGameID;
                mTestMatchedChatUsers.Add(TestMatchedChatUser);
            }


            UpdateMatchedChatTestStatueUI();

            ServerAddressRegistry.SaveGameID(2, StresssTestGameID);
            NetAddress serverAddress = MainWindow.Instance.GetServerAddressFromUI(1, MainWindow.Instance.stress_comboBoxIPAddress,
                                                                                  () =>
            {
                MainWindow.InitIPAdressComboBox(MainWindow.Instance.stress_comboBoxIPAddress, ServerAddressRegistry.GetServerAddresses(1));
            });

            //mLoginCurrectConnectedUser

            RunTestAction(serverAddress);


            m_MatchedChatTestTimer       = new DispatcherTimer();
            m_MatchedChatTestTimer.Tick += new EventHandler(
                (object ts, EventArgs te) =>
            {
                for (int i = 0; i < mTestMatchedChatUsers.Count; i++)
                {
                    mTestMatchedChatUsers[i].OnTimerTick(UpdateTick);
                }

                if (IsProgressFailed() && MainWindow.Instance.InfiniteReTryFailedRepeattCheck_MatchChat.IsChecked == true)
                {
                    mCurDealyReTryTime += UpdateTick;
                    if (mCurDealyReTryTime >= 1000)
                    {
                        mTickCount++;
                        mCurDealyReTryTime = 0;
                        PrintStatus(1, "Plz ReTry Test!! {0}..", 3 - mTickCount);
                        if (mTickCount == 3)
                        {
                            this.StartTest(true, 2);
                        }
                    }
                }
            });

            m_MatchedChatTestTimer.Interval = new TimeSpan(0, 0, 0, 0, UpdateTick);
            m_MatchedChatTestTimer.Start();
        }