// 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); } }
// serialize game data request data public bool Serialize(GameDataRequestData data) { // clear buffer Clear(); // serialize element bool result = true; result &= Serialize(data.playerID); // failure serialize -> method exit if (!result) { return(false); } // success serialize -> return result return(true); }
// deserialize game data request data public bool Deserialize(ref GameDataRequestData data) { // set deserialize data bool result = (GetDataSize() > 0) ? true : false; // data read failure -> method exit if (!result) { return(false); } // return data initialize string playerID; // data deserizlize result &= Deserialize(out playerID, (int)GetDataSize()); // input data data.playerID = playerID; // return result return(result); }