Example #1
0
        private void getMessageBeforeGame()
        {
            while (!freeThread)
            {
                try
                {
                    Network.Message m = clientLobby.ClientReceiveMsgText();
                    if (m.pseudo == "server")
                    {
                        switch (m.commande)
                        {
                        case Network.Commande.FREETHREAD:
                            freeThread = true;
                            break;

                        case Network.Commande.BEGIN:
                            if (m.data == "ok")
                            {
                                BeginOK();
                            }
                            else
                            {
                                BeginNoOk();
                            }
                            break;

                        case Network.Commande.REFRESH:
                            this.Invoke((Action) delegate
                            {
                                ClearPanelList();
                                CreatePanelList(m.data);
                            });
                            break;
                        }
                    }
                    else
                    {
                        //Affichage message tchat
                        if (readText != "")
                        {
                            readText = "" + m.data; readPseudo = "" + m.pseudo;
                            this.Invoke((Action) delegate
                            {
                                txtBoxTchat.AppendText(Environment.NewLine + readPseudo + " >> " + readText);
                            });
                        }
                    }
                    Console.WriteLine("FIN THREAD BEFORE");
                }

                catch (Exception e)
                {
                    freeThread = true;
                }
            }
        }
Example #2
0
        private void getMessage()
        {
            while (!freeThread)
            {
                Network.Message m = client.ClientReceiveMsgText();

                if (m.pseudo == "server")
                {
                    if (m.commande == Network.Commande.FREETHREAD)
                    {
                        Console.WriteLine("Free thread true");
                        freeThread = true;
                    }

                    else if (m.commande == Network.Commande.REFRESH)
                    {
                        this.Invoke((Action) delegate {
                            Thread.Sleep(250);
                            ClearPanelList();
                            CreatePanelList(m.data);
                        });
                    }
                }
                else
                {
                    if (readText != "")
                    {
                        readText = "" + m.data; readPseudo = "" + m.pseudo;
                        this.Invoke((Action) delegate {
                            txtBox_Tchat.AppendText(Environment.NewLine + readPseudo + " >> " + readText);
                        });
                    }
                }
            }
            Console.WriteLine("FIN THREAD LOBBY");
        }
Example #3
0
        /****************** MULTI COMMUNICATION METHODS ********************/
        static private void GetServerMessage()
        {
            try
            {
                while (!freeThread)
                {
                    Network.Message m = playerClient.ClientReceiveMsgText();
                    if (m.pseudo == "server")
                    {
                        switch (m.commande)
                        {
                        case Network.Commande.GIVESTACK:
                            SetStack(m.data);

                            break;

                        case Network.Commande.REMOVEDECKCARD:
                            RemoveCard();
                            break;

                        case Network.Commande.GIVECARD:
                            ReceiveCard(m.data);
                            break;

                        case Network.Commande.PLAYERTURN:
                            PlayerTurn(m.data);
                            break;

                        case Network.Commande.PICKCARD:
                            RefreshAfterPick(m.data);
                            break;

                        case Network.Commande.PLAYCARD:
                            String[] dataArray = m.data.Split('|');
                            RefreshAfterPlay(dataArray[1], dataArray[0]);
                            break;


                        //RECEIVING CARD EFFECT
                        case Network.Commande.GUARDEFFECT:
                            ReceiveGuardEffect(m.data);
                            break;

                        case Network.Commande.GUARDEFFECTRES:
                            //ReceiveGuardEffectRes(m.data);
                            break;


                        case Network.Commande.PRIESTEFFECT:
                            ReceivePriestEffect(m.data);
                            break;

                        case Network.Commande.BARONEFFECT:
                            ReceiveBaronEffect(m.data);
                            break;


                        case Network.Commande.HANDMAIDEEFFECT:
                            ReceiveHandmaidEffect(m.data);
                            break;

                        case Network.Commande.PRINCEEFFECTRES:
                            ReceivePrinceEffect(m.data);
                            break;

                        case Network.Commande.KINGEFFECTRES:
                            ReceiveKingEffect(m.data);
                            break;


                        case Network.Commande.PRINCESSEFECT:
                            ReceivePrincessEffect(m.data);
                            break;

                        //--------------------------------//
                        case Network.Commande.ROUNDOVER:
                            AskCloseThread();
                            RoundOver(m.data);
                            break;

                        case Network.Commande.PLAYCARDVISUALRES:
                            PlayCardVisual(m.data);
                            break;

                        case Network.Commande.GAMEISOVER:
                            GameIsOver(m.data);
                            break;

                        case Network.Commande.PLAYERLEAVE:
                            SomeOneLeave();
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                freeThread = true;
            }
        }