Esempio n. 1
0
        private bool handleJoinRoomReply()
        {
            int successCode = Int32.Parse(_client.myReceive(1));

            if (successCode == 0)
            {
                int numberOfQuestions = Int32.Parse(_client.myReceive(2));
                int timePerQuestion   = Int32.Parse(_client.myReceive(2));
                //success
                Hide();
                roomInterface room = new roomInterface(_client, timePerQuestion, numberOfQuestions);
                room.ShowDialog();
                lblStatus.Content = "success";
                Show();
                return(true);
            }
            else if (successCode == 1)
            {
                lblStatus.Content = "Error - room is full";
                return(false);
            }
            else if (successCode == 2)
            {
                lblStatus.Content = "Error - room doesnt exist";
                return(false);
            }
            else
            {
                lblStatus.Content = "Error - unexpected protocol code recieved";
                return(false);
            }
        }
Esempio n. 2
0
        public bool handleCreateRoomReply()
        {
            string success = _client.myReceive(1);

            if (success == "1")
            {
                lblStatus.Content = "room creation failed"; //server thinks user is still in a room
                return(false);
            }
            else if (success == "0")
            {
                //success
                Hide();
                roomInterface roomIn = new roomInterface(_client, Int32.Parse(_createRoomTimePerQuestion), Int32.Parse(_createRoomNumberOfQuestions));
                roomIn.ShowDialog();
                lblStatus.Content = "success";
                Show();
                return(true);
            }
            else
            {
                lblStatus.Content = "Error: unexepected code recieved";
                return(false);
            }
        }