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
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Security.Cryptography.X509Certificates;
|
|
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
|
|
{
|
|
public class MsgViewVariablesModifyRemote : NetMessage
|
|
{
|
|
#region REQUIRED
|
|
|
|
public const MsgGroups GROUP = MsgGroups.Command;
|
|
public const string NAME = nameof(MsgViewVariablesModifyRemote);
|
|
public MsgViewVariablesModifyRemote(INetChannel channel) : base(NAME, GROUP) { }
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// The session ID of the session to modify.
|
|
/// </summary>
|
|
public uint SessionId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Same deal as <see cref="ViewVariablesSessionRelativeSelector.PropertyIndex"/>.
|
|
/// </summary>
|
|
public object[] PropertyIndex { get; set; }
|
|
|
|
/// <summary>
|
|
/// The new value of the property.
|
|
/// </summary>
|
|
public object Value { get; set; }
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
|
{
|
|
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
|
SessionId = buffer.ReadUInt32();
|
|
{
|
|
var length = buffer.ReadInt32();
|
|
using var stream = buffer.ReadAsStream(length);
|
|
PropertyIndex = serializer.Deserialize<object[]>(stream);
|
|
}
|
|
{
|
|
var length = buffer.ReadInt32();
|
|
using var stream = buffer.ReadAsStream(length);
|
|
Value = serializer.Deserialize(stream);
|
|
}
|
|
}
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
|
{
|
|
var serializer = IoCManager.Resolve<IRobustSerializer>();
|
|
buffer.Write(SessionId);
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
serializer.Serialize(stream, PropertyIndex);
|
|
buffer.Write((int)stream.Length);
|
|
buffer.Write(stream.ToArray());
|
|
}
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
serializer.Serialize(stream, Value);
|
|
buffer.Write((int)stream.Length);
|
|
buffer.Write(stream.ToArray());
|
|
}
|
|
}
|
|
}
|
|
}
|