Пример #1
0
        // game data request
        public void ReceiveGameDataRequest(Socket clientSocket, byte[] data)
        {
            // packet serialize
            GameDataRequestPacket receivePacket       = new GameDataRequestPacket(data);
            GameDataRequestData   gameDataRequestData = receivePacket.GetData();

            // process
            List <StoreData> storeDataSet = new List <StoreData>();
            List <ItemData>  itemDataSet  = new List <ItemData>();

            dataProcessor.GetGameData(gameDataRequestData.playerID, storeDataSet, itemDataSet);

            // send store data
            foreach (StoreData element in storeDataSet)
            {
                StoreDataPacket sendPacket = new StoreDataPacket(element);

                networkProcessor.Send(clientSocket, sendPacket);
            }

            // send item data
            foreach (ItemData element in itemDataSet)
            {
                ItemDataPacket sendPacket = new ItemDataPacket(element);

                networkProcessor.Send(clientSocket, sendPacket);
            }
        }
Пример #2
0
        // store create request
        public void ReceiveStoreCreateRequest(Socket clientSocket, byte[] data)
        {
            // packet deserialize
            StoreCreateRequestPacket packet = new StoreCreateRequestPacket(data);
            StoreCreateRequestData   storeCreateRequestData = packet.GetData();

            // process
            StoreCreateResultData sendData      = new StoreCreateResultData();
            StoreData             sendStoreData = new StoreData();

            sendData.createResult = dataProcessor.StoreCreate(storeCreateRequestData, sendStoreData, out sendData.message);

            // serialize & send data - result
            StoreCreateResultPacket sendPacket = new StoreCreateResultPacket(sendData);

            networkProcessor.Send(clientSocket, sendPacket);

            if (sendData.createResult)
            {
                // serialize & send data
                StoreDataPacket sendStorePacket = new StoreDataPacket(sendStoreData);
                networkProcessor.Send(clientSocket, sendStorePacket);
            }
        }