コード例 #1
0
ファイル: Program.cs プロジェクト: mildbyte/ReQuiz
        static void Main(string[] args)
        {
            serverAddr = IPAddress.Parse(args[0]);
            port = 1234;
            username = RandomName();

            Console.WriteLine("ReQuiz stress tester.");

            QuestionReceiver questionReceiver = new QuestionReceiver(serverAddr, port, username);
            questionReceiver.QuestionsFetched += ReceivedQuestionsEvent;
            questionReceiver.ConnectFailed += ConnectFailedEvent;
            questionReceiver.ClientLog += LogEvent;
            questionReceiver.ReceiveQuestions();
            while (true)
            {
                Thread.Sleep(1);
            }
        }
コード例 #2
0
ファイル: frmStart.cs プロジェクト: mildbyte/ReQuiz
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (!isConnecting)
            {
                //Validate the IP address and the port
                try
                {
                    serverAddr = IPAddress.Parse(txtAddress.Text.Trim());
                    serverPort = int.Parse(txtPort.Text.Trim());
                } catch (FormatException ex) {
                    MessageBox.Show("You have entered an invalid IP address and/or port.",
                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtAddress.SelectAll();
                    txtAddress.Select();
                    return;
                }

                //Hide the address fields and show the connection progress
                isConnecting = true;
                btnConnect.Enabled = false;
                lblConnectionProgress.Visible = true;
                txtAddress.Visible = false;
                lblIPAddress.Visible = false;

                //Set up the component that will receive the questions
                QuestionReceiver questionReceiver = new QuestionReceiver(serverAddr, serverPort, Environment.UserName);
                //Windows username is used as the username

                //Set up the event handlers
                questionReceiver.ClientLog += LogEvent;
                questionReceiver.QuestionsFetched += OnConnectComplete;
                questionReceiver.ConnectFailed += OnConnectFailed;

                //Start the operation
                questionReceiver.ReceiveQuestions();
            }
        }