private void BeginReceiveCallback(IAsyncResult ar)
        {
            try
            {
                // get the client socket
                TcpClient client    = (TcpClient)ar.AsyncState;
                int       bytesRead = client.Client.EndReceive(ar);

                string message = System.Text.Encoding.ASCII.GetString(_buffer, 0, bytesRead); //ini si may laman kang message



                if (message.Contains("DISCONNECT"))
                {
                    ThreadHelper.Hide(this);
                    client.Client.Shutdown(SocketShutdown.Both);
                    client.Client.Close();
                }



                else if (message.Contains("StartGame"))
                {
                    ThreadHelper.PanelOut(this, panel1, false);
                    Receive();
                }

                else if (message.Contains("C1o2mpute"))
                {
                    int rawscore = Convert.ToInt32(bunifuCustomLabel5.Text);

                    ThreadHelper.SetText(this, label6, rawscore.ToString());

                    ThreadHelper.SetText(this, label10, Total);


                    double converted_total    = Convert.ToInt32(Total);
                    double converted_rawscore = rawscore;
                    double comp    = (converted_rawscore / converted_total) * 100;//bawal zero
                    int    compute = Convert.ToInt32(comp);

                    if (compute < Convert.ToInt32("60"))
                    {
                        ThreadHelper.SetText(this, label9, compute.ToString() + "% You Need Improvement, Study and Play!");
                    }
                    else if (compute == Convert.ToInt32("100"))
                    {
                        ThreadHelper.SetText(this, label9, compute.ToString() + "% Excellent!");
                    }

                    else
                    {
                        ThreadHelper.SetText(this, label9, compute.ToString() + "% Not Bad!, aim for a Perfect Score Next Time ");
                    }

                    ThreadHelper.PanelOut(this, panel4, true);
                    ThreadHelper.PanelOut(this, panel1, true);//for this panel4 to show because of dock

                    Receive();
                }

                else if (message.Contains("PleaseHideThis"))
                {
                    Send("DISCONNECT");
                    ThreadHelper.Hide(this);
                }

                else
                {
                    var array = message.Split('\n');

                    if (array[9].ToString().Contains("Quiz Bee"))//Game Format
                    {
                        this.Invoke((MethodInvoker)(() => bunifuCustomLabel9.Visible = false));
                        this.Invoke((MethodInvoker)(() => bunifuMetroTextbox2.Visible = false));
                        this.Invoke((MethodInvoker)(() => bunifuFlatButton7.Visible = false));
                    }
                    else
                    {
                        if (answered == false)
                        {
                            this.Invoke((MethodInvoker)(() => bunifuCustomLabel9.Visible = true));
                            this.Invoke((MethodInvoker)(() => bunifuMetroTextbox2.Visible = true));
                            this.Invoke((MethodInvoker)(() => bunifuFlatButton7.Visible = true));
                            this.Invoke((MethodInvoker)(() => puzzle_description = array[11].ToString()));
                            //this.Invoke((MethodInvoker)(() => MessageBox.Show(array[11].ToString()+array[11].Length.ToString())));
                        }
                    }



                    if (array[12].ToString() == "Multiple Choice")//Item Format
                    {
                        this.Invoke((MethodInvoker)(() => bunifuCustomLabel8.Text = (Convert.ToInt32(bunifuCustomLabel8.Text) + 1).ToString()));
                        ThreadHelper.PanelOut(this, panel2, false);
                        ThreadHelper.PanelOut(this, panel3, false);

                        ThreadHelper.lblAddLabel(this, label1, array[0].ToString());                //Question
                        ThreadHelper.btnAddTxtButton(this, bunifuFlatButton1, array[1].ToString()); //A
                        ThreadHelper.btnAddTxtButton(this, bunifuFlatButton2, array[2].ToString()); //B
                        ThreadHelper.btnAddTxtButton(this, bunifuFlatButton3, array[3].ToString()); //C
                        ThreadHelper.btnAddTxtButton(this, bunifuFlatButton4, array[4].ToString()); //D
                        correctanswer = array[5].ToString();                                        //CorrectAnswer
                        points        = array[8].ToString();

                        Total = array[10].ToString();

                        ThreadHelper.ControlHide(this, bunifuFlatButton1, true);
                        ThreadHelper.ControlHide(this, bunifuFlatButton2, true);
                        ThreadHelper.ControlHide(this, bunifuFlatButton3, true);
                        ThreadHelper.ControlHide(this, bunifuFlatButton4, true);
                        ThreadHelper.imgbtnIN(this, bunifuImageButton1, false);
                        ThreadHelper.BunifuBoxHide(this, bunifuMetroTextbox1, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton5, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton6, false);


                        string str   = array[7].ToString();
                        int    index = str.IndexOf('(');

                        if (index >= 0)
                        {
                            time = str.Substring(0, index);
                        }
                        else
                        {
                            time = str;
                        }


                        convertedtime = Convert.ToInt32(time);//timer


                        string cut = array[7].ToString();
                        int    ind = cut.IndexOf('(');
                        string form;
                        if (ind >= 0)
                        {
                            form = cut.Substring(ind + 1, 7);
                        }
                        else
                        {
                            form = cut;
                        }


                        if (form == "Minutes")
                        {
                            convertedtime = convertedtime * 60;
                        }



                        this.Invoke(new ThreadStart(delegate() { timer1.Enabled = true; timer1.Start(); }));
                    }
                    else if (array[12].ToString() == "True/False")
                    {
                        this.Invoke((MethodInvoker)(() => bunifuCustomLabel8.Text = (Convert.ToInt32(bunifuCustomLabel8.Text) + 1).ToString()));
                        ThreadHelper.PanelOut(this, panel2, false);
                        ThreadHelper.PanelOut(this, panel3, false);

                        ThreadHelper.lblAddLabel(this, label1, array[0].ToString()); //Question
                        correctanswer = array[5].ToString();                         //CorrectAnswer
                        points        = array[8].ToString();
                        Total         = array[10].ToString();

                        ThreadHelper.imgbtnIN(this, bunifuImageButton1, false);
                        ThreadHelper.BunifuBoxHide(this, bunifuMetroTextbox1, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton1, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton2, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton3, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton4, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton5, true);
                        ThreadHelper.ControlHide(this, bunifuFlatButton6, true);



                        string str   = array[7].ToString();
                        int    index = str.IndexOf('(');

                        if (index >= 0)
                        {
                            time = str.Substring(0, index);
                        }
                        else
                        {
                            time = str;
                        }


                        convertedtime = Convert.ToInt32(time);//timer



                        string cut = array[7].ToString();
                        int    ind = cut.IndexOf('(');
                        string form;
                        if (ind >= 0)
                        {
                            form = cut.Substring(ind + 1, 7);
                        }
                        else
                        {
                            form = cut;
                        }


                        if (form == "Minutes")
                        {
                            convertedtime = convertedtime * 60;
                        }



                        this.Invoke(new ThreadStart(delegate() { timer1.Enabled = true; timer1.Start(); }));
                    }

                    else
                    {
                        this.Invoke((MethodInvoker)(() => bunifuCustomLabel8.Text = (Convert.ToInt32(bunifuCustomLabel8.Text) + 1).ToString()));
                        ThreadHelper.PanelOut(this, panel2, false);
                        ThreadHelper.PanelOut(this, panel3, false);

                        ThreadHelper.lblAddLabel(this, label1, array[0].ToString()); //Question
                        correctanswer = array[5].ToString();;                        //CorrectAnswer
                        points        = array[8].ToString();
                        Total         = array[10].ToString();

                        ThreadHelper.imgbtnIN(this, bunifuImageButton1, true);
                        ThreadHelper.BunifuBoxHide(this, bunifuMetroTextbox1, true);
                        ThreadHelper.ControlHide(this, bunifuFlatButton1, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton2, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton3, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton4, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton5, false);
                        ThreadHelper.ControlHide(this, bunifuFlatButton6, false);

                        string str   = array[7].ToString();
                        int    index = str.IndexOf('(');

                        if (index >= 0)
                        {
                            time = str.Substring(0, index);
                        }
                        else
                        {
                            time = str;
                        }


                        convertedtime = Convert.ToInt32(time);//timer



                        string cut = array[7].ToString();
                        int    ind = cut.IndexOf('(');
                        string form;
                        if (ind >= 0)
                        {
                            form = cut.Substring(ind + 1, 7);
                        }
                        else
                        {
                            form = cut;
                        }


                        if (form == "Minutes")
                        {
                            convertedtime = convertedtime * 60;
                        }


                        this.Invoke(new ThreadStart(delegate() { timer1.Enabled = true; timer1.Start(); }));
                    }



                    Receive();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }