Upload another progress
This commit is contained in:
parent
369d4c7b9b
commit
a50dc78dd0
4 changed files with 19 additions and 15 deletions
|
@ -1,10 +1,8 @@
|
|||
using System.Text;
|
||||
using Lagrange.Core.Common;
|
||||
using Lagrange.Core.Core.Event.Protocol.System;
|
||||
using Lagrange.Core.Core.Packets.Service.Highway;
|
||||
using Lagrange.Core.Utility.Binary;
|
||||
using Lagrange.Core.Utility.Extension;
|
||||
using ProtoBuf;
|
||||
using ProtoBuf.Meta;
|
||||
|
||||
namespace Lagrange.Core.Core.Context;
|
||||
|
||||
|
@ -15,6 +13,13 @@ internal class HighwayContext : ContextBase
|
|||
{
|
||||
private readonly HttpClient _client;
|
||||
private uint _sequence;
|
||||
private static readonly RuntimeTypeModel Serializer;
|
||||
|
||||
static HighwayContext()
|
||||
{
|
||||
Serializer = RuntimeTypeModel.Create();
|
||||
Serializer.UseImplicitZeroDefaults = false;
|
||||
}
|
||||
|
||||
public HighwayContext(ContextCollection collection, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device)
|
||||
: base(collection, keystore, appInfo, device)
|
||||
|
@ -28,7 +33,7 @@ internal class HighwayContext : ContextBase
|
|||
_client.DefaultRequestHeaders.Add("Accept-Encoding", "identity");
|
||||
_client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2)");
|
||||
|
||||
_sequence = 10000;
|
||||
_sequence = 0;
|
||||
}
|
||||
|
||||
public async Task<bool> EchoAsync()
|
||||
|
@ -44,9 +49,7 @@ internal class HighwayContext : ContextBase
|
|||
Command = "PicUp.Echo",
|
||||
Seq = Interlocked.Increment(ref _sequence),
|
||||
AppId = (uint)AppInfo.SubAppId,
|
||||
DataFlag = 4096,
|
||||
CommandId = 0,
|
||||
LocaleId = 2052
|
||||
CommandId = 0
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -72,6 +75,7 @@ internal class HighwayContext : ContextBase
|
|||
int offset = 0;
|
||||
int chunkSize = fileSize is >= 1024 and <= 1048575 ? 8192 : 1024 * 1024;
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
int concurrent = commonId == 2 ? 1 : 8;
|
||||
|
||||
while (offset < fileSize)
|
||||
{
|
||||
|
@ -81,7 +85,7 @@ internal class HighwayContext : ContextBase
|
|||
upBlocks.Add(reqBody);
|
||||
offset += payload;
|
||||
|
||||
if (upBlocks.Count >= 8 || data.Position == data.Length)
|
||||
if (upBlocks.Count >= concurrent || data.Position == data.Length)
|
||||
{
|
||||
var tasks = upBlocks.Select(x => SendUpBlockAsync(x, uri)).ToArray();
|
||||
var results = await Task.WhenAll(tasks);
|
||||
|
|
|
@ -17,13 +17,13 @@ internal class DataHighwayHead
|
|||
|
||||
[ProtoMember(6)] public uint AppId { get; set; }
|
||||
|
||||
[ProtoMember(7)] public uint DataFlag { get; set; }
|
||||
// [ProtoMember(7)] public uint DataFlag { get; set; }
|
||||
|
||||
[ProtoMember(8)] public uint CommandId { get; set; }
|
||||
|
||||
[ProtoMember(9)] public byte[]? BuildVer { get; set; }
|
||||
|
||||
[ProtoMember(10)] public uint LocaleId { get; set; }
|
||||
// [ProtoMember(10)] public uint LocaleId { get; set; }
|
||||
|
||||
[ProtoMember(11)] public uint EnvId { get; set; }
|
||||
// [ProtoMember(11)] public uint EnvId { get; set; }
|
||||
}
|
|
@ -17,7 +17,7 @@ internal class SegHead
|
|||
|
||||
[ProtoMember(6)] public string ServiceTicket { get; set; } = string.Empty;
|
||||
|
||||
[ProtoMember(7)] public uint Flag { get; set; }
|
||||
// [ProtoMember(7)] public uint Flag { get; set; }
|
||||
|
||||
[ProtoMember(8)] public byte[] Md5 { get; set; } = Array.Empty<byte>();
|
||||
|
||||
|
@ -25,9 +25,9 @@ internal class SegHead
|
|||
|
||||
[ProtoMember(10)] public uint CacheAddr { get; set; }
|
||||
|
||||
[ProtoMember(11)] public uint QueryTimes { get; set; }
|
||||
// [ProtoMember(11)] public uint QueryTimes { get; set; }
|
||||
|
||||
[ProtoMember(12)] public uint UpdateCacheIp { get; set; }
|
||||
// [ProtoMember(12)] public uint UpdateCacheIp { get; set; }
|
||||
|
||||
[ProtoMember(13)] public uint CachePort { get; set; }
|
||||
}
|
|
@ -101,7 +101,7 @@ public class ImageEntity : IMessageEntity
|
|||
Origin = 1,
|
||||
ThumbWidth = 0,
|
||||
ThumbHeight = 0,
|
||||
PbReserve = new CustomFaceExtra { Field1 = 1 }
|
||||
PbReserve = new CustomFaceExtra { Field1 = 0 }
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue