Итоговое уменьшение передаваемой информации в 4 раза

This commit is contained in:
2025-02-27 09:01:21 +03:00
parent 5718f9c313
commit 906bda7000
8 changed files with 18 additions and 14 deletions
+2 -2
View File
@@ -11,11 +11,11 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants /> <DefineConstants>TRACE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants /> <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+1 -1
View File
@@ -34,7 +34,7 @@ class Program
})); }));
builder.SetupMethodsRepository(new CoCodegenMethodRepository()); builder.SetupMethodsRepository(new CoCodegenMethodRepository());
builder.Modules.Add(new CreativeRepresentationModuleProducer( builder.Modules.Add(new CreativeRepresentationModuleProducer(
new IInjectableModule[] { builder.GetModule<CborSerializationToolkit>()! }, new IInjectableModule[] { builder.GetModule<ISerializationToolkit>()! },
typeof(RepresentationModule))); typeof(RepresentationModule)));
builder.Modules.Add(new CancellationRepository()); builder.Modules.Add(new CancellationRepository());
+1 -1
View File
@@ -14,7 +14,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants /> <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
-4
View File
@@ -1,5 +1,4 @@
using System; using System;
using System.Text.Json.Serialization;
using mROA.Implementation.Attributes; using mROA.Implementation.Attributes;
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global
@@ -21,9 +20,6 @@ namespace mROA.Implementation
public int CommandId { get; set; } public int CommandId { get; set; }
public int ObjectId { get; set; } = -1; public int ObjectId { get; set; } = -1;
[SerializationIgnore]
public Type? ParameterType { get; set; }
public object? Parameter { get; set; } public object? Parameter { get; set; }
public override string ToString() public override string ToString()
{ {
@@ -82,6 +82,7 @@ namespace mROA.Implementation
var len = BitConverter.ToUInt16(new[] { firstBit, secondBit}); var len = BitConverter.ToUInt16(new[] { firstBit, secondBit});
var localSpan = _buffer.Slice(0, len); var localSpan = _buffer.Slice(0, len);
await BaseStream.ReadExactlyAsync(localSpan); await BaseStream.ReadExactlyAsync(localSpan);
// Console.WriteLine("Receiving {0}", Encoding.Default.GetString(_buffer[..len])); // Console.WriteLine("Receiving {0}", Encoding.Default.GetString(_buffer[..len]));
@@ -89,6 +90,8 @@ namespace mROA.Implementation
var message = _serialization.Deserialize<NetworkMessage>(localSpan.Span); var message = _serialization.Deserialize<NetworkMessage>(localSpan.Span);
#if TRACE #if TRACE
Console.WriteLine($"Received Message {message.SchemaId} - {message.Id}"); Console.WriteLine($"Received Message {message.SchemaId} - {message.Id}");
TransmissionConfig.TotalTransmittedBytes += len;
Console.WriteLine($"Total recieced bytes are {TransmissionConfig.TotalTransmittedBytes}");
#endif #endif
_messageBuffer.Add(message); _messageBuffer.Add(message);
_currentReceiving = Task.Run(async () => await GetNextMessage()); _currentReceiving = Task.Run(async () => await GetNextMessage());
+4 -2
View File
@@ -26,7 +26,8 @@ namespace mROA.Implementation
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var request = new DefaultCallRequest var request = new DefaultCallRequest
{ CommandId = methodId, ObjectId = _id, Parameter = parameter, ParameterType = parameter?.GetType() }; { CommandId = methodId, ObjectId = _id, Parameter = parameter
};
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CallRequest, request); await _representationModule.PostCallMessageAsync(request.Id, MessageType.CallRequest, request);
@@ -79,7 +80,8 @@ namespace mROA.Implementation
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var request = new DefaultCallRequest var request = new DefaultCallRequest
{ CommandId = methodId, ObjectId = _id, Parameter = parameter, ParameterType = parameter?.GetType() }; { CommandId = methodId, ObjectId = _id, Parameter = parameter
};
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CallRequest, request); await _representationModule.PostCallMessageAsync(request.Id, MessageType.CallRequest, request);
var localTokenSource = new CancellationTokenSource(); var localTokenSource = new CancellationTokenSource();
+6 -3
View File
@@ -11,6 +11,9 @@ namespace mROA.Implementation
{ {
public static class TransmissionConfig public static class TransmissionConfig
{ {
#if TRACE
public static int TotalTransmittedBytes { get; set; } = 0;
#endif
private static IContextRepository? _realContextRepository; private static IContextRepository? _realContextRepository;
private static IContextRepository? _remoteEndpointContextRepository; private static IContextRepository? _remoteEndpointContextRepository;
private static IOwnershipRepository? _ownershipRepository; private static IOwnershipRepository? _ownershipRepository;
@@ -43,6 +46,7 @@ namespace mROA.Implementation
public class SharedObject<T> : ISharedObject where T : notnull public class SharedObject<T> : ISharedObject where T : notnull
{ {
[SerializationIgnore] [SerializationIgnore]
[JsonIgnore]
public IEndPointContext EndPointContext { get; set; } = new EndPointContext public IEndPointContext EndPointContext { get; set; } = new EndPointContext
{ {
RealRepository = TransmissionConfig.RealContextRepository, RealRepository = TransmissionConfig.RealContextRepository,
@@ -50,6 +54,7 @@ namespace mROA.Implementation
HostId = TransmissionConfig.OwnershipRepository.GetHostOwnershipId(), HostId = TransmissionConfig.OwnershipRepository.GetHostOwnershipId(),
OwnerFunc = TransmissionConfig.OwnershipRepository.GetOwnershipId OwnerFunc = TransmissionConfig.OwnershipRepository.GetOwnershipId
}; };
private IContextRepository GetDefaultContextRepository() => private IContextRepository GetDefaultContextRepository() =>
(OwnerId == EndPointContext.HostId (OwnerId == EndPointContext.HostId
? EndPointContext.RealRepository ? EndPointContext.RealRepository
@@ -89,8 +94,7 @@ namespace mROA.Implementation
} }
} }
[SerializationIgnore] [JsonIgnore] [SerializationIgnore] public T Value { get; private set; }
public T Value { get; private set; }
// ReSharper disable once MemberCanBePrivate.Global // ReSharper disable once MemberCanBePrivate.Global
// ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedMember.Global
@@ -116,6 +120,5 @@ namespace mROA.Implementation
public static implicit operator SharedObject<T>(T value) => public static implicit operator SharedObject<T>(T value) =>
new(value); new(value);
} }
} }
+1 -1
View File
@@ -21,7 +21,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants /> <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>