mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* make lidgren use spans everywhere where it can convert custom pooling to shared array pool impl add unit tests for read/write add native socket extensions to socket so we can legit pass spans for SendTo/ReceiveFrom bump version in lidgren csproj replace some random "% 8" w/ "& 7" more minor nullability hacks to fix static analysis complaints made receiving packets use span minor native sockets refactor to use pinvoke add read/write constrained/prealloc'd bit stream impl to lidgren and update usages fixed missing stream cleanup remove outstanding stream cleanup since it refs buffer thru the class, can't read some other buf apply suggestions from code review remove unsafe cruft * add tests to gh actions * make stats use interpolation in tostring and remove m_bytesAllocated since it's all in the shared pool now * this pr still open so fuck it stats, human readability, faster BitsToHold methods * add api compatible version of ReadBytes * rename ReadOnlyStreamWrapper -> ReadOnlyWrapperStream rename WriteOnlyStreamWrapper -> WriteOnlyWrapperStream add AppendViaStream, AppenderStream impl add and update documentation on read/write bytes methods also fix some goofs
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System.IO;
|
|
using Lidgren.Network;
|
|
using Robust.Shared.Interfaces.Network;
|
|
using Robust.Shared.Interfaces.Serialization;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
#nullable disable
|
|
|
|
namespace Robust.Shared.Network.Messages
|
|
{
|
|
/// <summary>
|
|
/// Sent server to client to contain object data read by VV.
|
|
/// </summary>
|
|
public class MsgViewVariablesRemoteData : NetMessage
|
|
{
|
|
#region REQUIRED
|
|
|
|
public const MsgGroups GROUP = MsgGroups.Command;
|
|
public const string NAME = nameof(MsgViewVariablesRemoteData);
|
|
|
|
public MsgViewVariablesRemoteData(INetChannel channel) : base(NAME, GROUP)
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// The request ID equal to the ID sent in <see cref="RequestId"/>,
|
|
/// to identify multiple, potentially concurrent, requests.
|
|
/// </summary>
|
|
public uint RequestId { get; set; }
|
|
|
|
/// <summary>
|
|
/// The data blob containing the requested data.
|
|
/// </summary>
|
|
public ViewVariablesBlob Blob { get; set; }
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
|
{
|
|
RequestId = buffer.ReadUInt32();
|
|
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
|
var length = buffer.ReadInt32();
|
|
using var stream = buffer.ReadAsStream(length);
|
|
Blob = serializer.Deserialize<ViewVariablesBlob>(stream);
|
|
}
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
|
{
|
|
buffer.Write(RequestId);
|
|
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
serializer.Serialize(stream, Blob);
|
|
buffer.Write((int)stream.Length);
|
|
buffer.Write(stream.ToArray());
|
|
}
|
|
}
|
|
}
|
|
}
|