Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 15c66a9

Browse files
authored
[Core] Stream Message (#795)
1 parent c29428c commit 15c66a9

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using ProtoBuf;
2+
3+
namespace Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra;
4+
5+
[ProtoContract]
6+
public class StreamExtra
7+
{
8+
[ProtoMember(43)] public ulong Field43 { get; init; }
9+
10+
[ProtoMember(103)] public ulong Sequence { get; init; }
11+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Lagrange.Core.Internal.Packets.Message.Element;
2+
using Lagrange.Core.Internal.Packets.Message.Element.Implementation;
3+
using Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra;
4+
using ProtoBuf;
5+
6+
namespace Lagrange.Core.Message.Entity;
7+
8+
public class StreamEntity : IMessageEntity
9+
{
10+
public string Text { get; }
11+
12+
public StreamEntity(string text)
13+
{
14+
Text = text;
15+
}
16+
17+
IEnumerable<Elem> IMessageEntity.PackElement()
18+
{
19+
byte[] extra;
20+
using (MemoryStream stream = new())
21+
{
22+
Serializer.Serialize(stream, new StreamExtra
23+
{
24+
Field43 = (ulong)Random.Shared.NextInt64(),
25+
Sequence = 1
26+
});
27+
extra = stream.ToArray();
28+
}
29+
30+
return new Elem[] {
31+
new() {
32+
Text = new Text {
33+
Str = Text
34+
}
35+
},
36+
new() {
37+
GeneralFlags = new GeneralFlags {
38+
PbReserve = extra
39+
}
40+
}
41+
};
42+
}
43+
44+
IMessageEntity? IMessageEntity.UnpackElement(Elem elem) => throw new NotImplementedException();
45+
46+
string IMessageEntity.ToPreviewString() => $"[Stream] {Text}";
47+
}

0 commit comments

Comments
 (0)