Exemple #1
0
        static void ServerOnRecv(int remoteID, byte[] accptBytes)
        {
            TOPBYTE topbyte = (TOPBYTE)accptBytes[0];

            accptBytes = VisionFunctions.DeleteTopByte(accptBytes);
            if (topbyte == TOPBYTE.STRING)
            {
                string sendStr;
                sendStr = VisionFunctions.DeserializeToString(accptBytes);
                //fm1.Chat_Add(string.Format("server:client{0}からの通信>{1}", remoteID, accptStr));
                sv.Broadcast(sendStr, TOPBYTE.STRING);
            }
            else if (topbyte == TOPBYTE.NETVISIONCORE)
            {
                NetvisionCore accptCore = new NetvisionCore();
                accptCore.setAll(VisionFunctions.DeserializeToNetvisionCore(accptBytes));
                if (remoteID == sv.player1)
                {
                    sv.core.setAll(accptCore);
                }
                else if (remoteID == sv.player2)
                {
                    sv.core.setAll(accptCore.ReverseSide());
                }

                // 返信
                sv.BroadcastCore();
            }
            else if (topbyte == TOPBYTE.DECK)
            {
                Card[] accptDeck = new Card[50];
                accptDeck = VisionFunctions.DeserializeToDeck(accptBytes);
                if (remoteID == sv.player1)
                {
                    for (int i = 0; i < 50; i++)
                    {
                        sv.core.cards[i].setAll(accptDeck[i]);
                    }
                }
                else if (remoteID == sv.player2)
                {
                    for (int i = 0; i < 50; i++)
                    {
                        sv.core.cards[50 + i].setAll(accptDeck[i]);
                    }
                }

                if (svStat == SERVERSTAT.PLAYING)
                {
                    sv.StartGame();
                    sv.BroadcastCore();
                }
            }
            else
            {
                string sendStr;
                sendStr = accptBytes.Length.ToString();
                sv.Broadcast(sendStr, TOPBYTE.STRING);
            }
        }
Exemple #2
0
        static void ClientOnRecv(int remoteID, byte[] accptBytes)
        {
            byte[]        accptBytes2 = VisionFunctions.DeleteTopByte(accptBytes);
            string        accptStr;
            NetvisionCore accptCore;

            switch ((TOPBYTE)accptBytes[0])
            {
            case TOPBYTE.STRING:
                accptStr = VisionFunctions.DeserializeToString(accptBytes2);
                fm1.Chat_Add(string.Format("client:server{0}からの通信>{1}", remoteID, accptStr));
                break;

            case TOPBYTE.NETVISIONCORE:
                accptCore = VisionFunctions.DeserializeToNetvisionCore(accptBytes2);
                fm1.setNetvisionCore(accptCore);
                break;
            }
        }