-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve transfer speed (sending) (#178)
- Loading branch information
1 parent
eafdf2d
commit eb8135d
Showing
14 changed files
with
751 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
<Project> | ||
<ItemGroup Label="Global Dependencies"> | ||
<PackageReference Include="ShortDev.IO" Version="0.1.3" /> | ||
<PackageReference Include="ShortDev.IO" Version="0.1.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Label="Global Usings"> | ||
<Using Include="ShortDev.IO" /> | ||
<Using Include="ShortDev.IO.Input" /> | ||
<Using Include="ShortDev.IO.Output" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Label="Tests"> | ||
<InternalsVisibleTo Include="ShortDev.Microsoft.ConnectedDevices.Test" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/ShortDev.Microsoft.ConnectedDevices.NearShare/Messages/FetchDataResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using ShortDev.Microsoft.ConnectedDevices.Serialization; | ||
|
||
namespace ShortDev.Microsoft.ConnectedDevices.NearShare.Messages; | ||
internal static class FetchDataResponse | ||
{ | ||
public static void Write(EndianWriter writer, uint contentId, ulong start, int length, out Span<byte> blob) | ||
{ | ||
CompactBinaryBondWriter bondWriter = new(writer.Buffer); | ||
|
||
bondWriter.WriteFieldBegin(Bond.BondDataType.BT_MAP, 1); | ||
bondWriter.WriteContainerBegin(count: 4, Bond.BondDataType.BT_WSTRING, Bond.BondDataType.BT_STRUCT); | ||
|
||
WritePropertyBegin(ref bondWriter, "ControlMessage", PropertyType.PropertyType_UInt32); | ||
bondWriter.WriteFieldBegin(Bond.BondDataType.BT_UINT32, 104); | ||
bondWriter.WriteUInt32((uint)NearShareControlMsgType.FetchDataResponse); | ||
bondWriter.WriteStructEnd(); | ||
|
||
WritePropertyBegin(ref bondWriter, "ContentId", PropertyType.PropertyType_UInt32); | ||
bondWriter.WriteFieldBegin(Bond.BondDataType.BT_UINT32, 104); | ||
bondWriter.WriteUInt32(contentId); | ||
bondWriter.WriteStructEnd(); | ||
|
||
WritePropertyBegin(ref bondWriter, "BlobPosition", PropertyType.PropertyType_UInt64); | ||
bondWriter.WriteFieldBegin(Bond.BondDataType.BT_UINT64, 106); | ||
bondWriter.WriteUInt64(start); | ||
bondWriter.WriteStructEnd(); | ||
|
||
WritePropertyBegin(ref bondWriter, "DataBlob", PropertyType.PropertyType_UInt8Array); | ||
bondWriter.WriteFieldBegin(Bond.BondDataType.BT_LIST, 200); | ||
bondWriter.WriteContainerBegin(length, Bond.BondDataType.BT_UINT8); | ||
|
||
blob = writer.Buffer.GetSpan(length)[..length]; | ||
writer.Buffer.Advance(length); | ||
|
||
bondWriter.WriteStructEnd(); | ||
|
||
bondWriter.WriteStructEnd(); | ||
} | ||
|
||
static void WritePropertyBegin(ref CompactBinaryBondWriter writer, string name, PropertyType type) | ||
{ | ||
writer.WriteWString(name); | ||
|
||
writer.WriteFieldBegin(Bond.BondDataType.BT_INT32, 0); | ||
writer.WriteInt32((int)type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.