mirror of
https://github.com/quasar/Quasar.git
synced 2026-10-22 00:15:56 +08:00
e4757b87a2
- Added blocking send, this is important when transfering files to prevent allocation of all blocks at once which pumps the memory with the files contents
49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using ProtoBuf;
|
|
using xClient.Core.Networking;
|
|
|
|
namespace xClient.Core.Packets.ClientPackets
|
|
{
|
|
[ProtoContract]
|
|
public class DoDownloadFileResponse : IPacket
|
|
{
|
|
[ProtoMember(1)]
|
|
public int ID { get; set; }
|
|
|
|
[ProtoMember(2)]
|
|
public string Filename { get; set; }
|
|
|
|
[ProtoMember(3)]
|
|
public byte[] Block { get; set; }
|
|
|
|
[ProtoMember(4)]
|
|
public int MaxBlocks { get; set; }
|
|
|
|
[ProtoMember(5)]
|
|
public int CurrentBlock { get; set; }
|
|
|
|
[ProtoMember(6)]
|
|
public string CustomMessage { get; set; }
|
|
|
|
public DoDownloadFileResponse()
|
|
{
|
|
}
|
|
|
|
public DoDownloadFileResponse(int id, string filename, byte[] block, int maxblocks, int currentblock,
|
|
string custommessage)
|
|
{
|
|
this.ID = id;
|
|
this.Filename = filename;
|
|
this.Block = block;
|
|
this.MaxBlocks = maxblocks;
|
|
this.CurrentBlock = currentblock;
|
|
this.CustomMessage = custommessage;
|
|
}
|
|
|
|
public void Execute(Client client)
|
|
{
|
|
// block thread till send queue is empty to prevent
|
|
// allocation of all blocks at once
|
|
client.SendBlocking(this);
|
|
}
|
|
}
|
|
} |