You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Network/FileTransfer/Model/FileStartFrame.cs

43 lines
1.2 KiB

6 years ago
using System.Threading;
using ZeroLevel.Services.Serialization;
6 years ago
namespace ZeroLevel.Network.FileTransfer
6 years ago
{
public sealed class FileStartFrame
6 years ago
: IBinarySerializable, IFileTransferInfo
6 years ago
{
6 years ago
private static long _uploadTaskIdCounter = 0;
6 years ago
6 years ago
public FileTransferInfoType TransferInfoType => FileTransferInfoType.Start;
public long UploadFileTaskId { get; set; }
6 years ago
public string FilePath;
public long Size;
public void Serialize(IBinaryWriter writer)
{
6 years ago
writer.WriteLong(this.UploadFileTaskId);
6 years ago
writer.WriteString(this.FilePath);
writer.WriteLong(this.Size);
}
public void Deserialize(IBinaryReader reader)
{
6 years ago
this.UploadFileTaskId = reader.ReadLong();
6 years ago
this.FilePath = reader.ReadString();
this.Size = reader.ReadLong();
}
public static FileStartFrame GetTransferFileInfo(string path)
{
var fi = new System.IO.FileInfo(path);
return new FileStartFrame
{
FilePath = fi.FullName,
6 years ago
UploadFileTaskId = Interlocked.Increment(ref _uploadTaskIdCounter),
6 years ago
Size = fi.Length
};
}
}
}

Powered by TurnKey Linux.