/// <summary>
 /// Handle query.
 /// </summary>
 /// <param name="sourceUserID">source user id</param>
 /// <param name="informationType">information type</param>
 /// <param name="information">information</param>
 /// <returns>result</returns>
 public byte[] HandleQuery(string sourceUserID, int informationType, byte[] information)
 {
     if (informationType == InformationTypes.GetAllFilesInfo)
     {
         FilesInfoContract filesInfoContract = new FilesInfoContract
         {
             AllFileInfoList = mUpdateConfiguration.FileList
         };
         return(CompactPropertySerializer.Default.Serialize(filesInfoContract));
     }
     else if (informationType == InformationTypes.GetLatestUpdateTime)
     {
         LatestUpdateTimeContract latestUpdateTimeContract = new LatestUpdateTimeContract(mUpdateConfiguration.ClientVersion);
         return(CompactPropertySerializer.Default.Serialize(latestUpdateTimeContract));
     }
     return(null);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get update information.
        /// </summary>
        private void GetUpdateInfo(out IList <string> fileRelativePathListNeedDownloaded, out IList <FileUnit> fileListNeedRemoved)
        {
            byte[] latestUpdateTime = mRapidPassiveEngine.CustomizeOutter.Query(InformationTypes.GetLatestUpdateTime, null);
            LatestUpdateTimeContract latestUpdateTimeContract = CompactPropertySerializer.Default.Deserialize <LatestUpdateTimeContract>(latestUpdateTime, 0);

            fileRelativePathListNeedDownloaded = new List <string>();
            fileListNeedRemoved = new List <FileUnit>();

            if (mUpdateConfiguration.ClientVersion != latestUpdateTimeContract.ClientVersion)
            {
                byte[]            fileInfoBytes     = mRapidPassiveEngine.CustomizeOutter.Query(InformationTypes.GetAllFilesInfo, null);
                FilesInfoContract filesInfoContract = CompactPropertySerializer.Default.Deserialize <FilesInfoContract>(fileInfoBytes, 0);

                foreach (FileUnit file in mUpdateConfiguration.FileList)
                {
                    FileUnit fileAtServer = ContainsFile(file.FileRelativePath, filesInfoContract.AllFileInfoList);
                    if (fileAtServer != null)
                    {
                        if (file.Version < fileAtServer.Version)
                        {
                            fileRelativePathListNeedDownloaded.Add(file.FileRelativePath);
                        }
                    }
                    else
                    {
                        fileListNeedRemoved.Add(file);
                    }
                }

                foreach (FileUnit file in filesInfoContract.AllFileInfoList)
                {
                    FileUnit fileAtServer = ContainsFile(file.FileRelativePath, mUpdateConfiguration.FileList);
                    if (fileAtServer == null)
                    {
                        fileRelativePathListNeedDownloaded.Add(file.FileRelativePath);
                    }
                }
                mUpdateConfiguration.FileList      = filesInfoContract.AllFileInfoList;
                mUpdateConfiguration.ClientVersion = latestUpdateTimeContract.ClientVersion;
            }
        }