Exemple #1
0
        public override void ExecuteCommand(UpLoadClientEngine session, TransferCommandInfo commandInfo)
        {
            bool result = session.OnFileExist();

            if (result)
            {
                byte[] data = SerializeHelp.Serialize <UpLoadInfo>(session.UpLoadInfo);
                session.SendData(UpLoadOP.DoCover, data, 0, data.Length);
            }
            else
            {
                session.DoEnd();
            }
        }
        internal void DoUpLoad(UpLoadInfo ClientConfigInfo)
        {
            string saveName     = Path.GetFullPath(ClientConfigInfo.SaveName);
            string saveTempName = saveName + TransferCommon.Config.TempSuffix;

            TransferCommon.UpLoadInfo ServerConfigInfo = null;
            string configName   = ClientConfigInfo.SaveName + TransferCommon.Config.ConfigSuffix;
            string saveNamePath = Path.GetDirectoryName(saveName);

            if (!Directory.Exists(saveNamePath))
            {
                Directory.CreateDirectory(saveNamePath);
            }
            if (File.Exists(saveTempName))
            {
                this.m_fileStream = new FileStream(saveTempName, FileMode.Open, FileAccess.Write);
                if (File.Exists(configName))
                {
                    ServerConfigInfo = SerializeHelp.DeserializeFromFile <UpLoadInfo>(configName);
                }
            }
            else
            {
                this.m_fileStream = new FileStream(saveTempName, FileMode.Create, FileAccess.Write);
                this.m_fileStream.SetLength(ClientConfigInfo.FileSize);
            }
            if (ServerConfigInfo == null)
            {
                ServerConfigInfo = ClientConfigInfo;
                SerializeHelp.SerializeToFile <UpLoadInfo>(ServerConfigInfo, configName);
            }
            //如果客户端传来的已上传大小与服务端的已上传大小不一致
            //if(ServerConfigInfo.TransferedLength!= ClientConfigInfo.TransferedLength)
            //{

            //}
            //如果客户端传来的文件大小与服务端的文件大小不一致
            //to do something
            this.UpLoadInfo            = ServerConfigInfo;
            this.m_fileStream.Position = ServerConfigInfo.TransferPos + ServerConfigInfo.TransferedLength;
            byte[] data = SerializeHelp.Serialize <UpLoadInfo>(ServerConfigInfo);
            this.SendData(UpLoadOP.DoUpLoad, data, 0, data.Length);
        }
Exemple #3
0
 internal void UserJoin(User user)
 {
     byte[] data = SerializeHelp.Serialize <User>(user);
     SendData(UserOP.DoUserJoin, data);
 }