Практически работает

This commit is contained in:
2025-03-10 17:35:16 +03:00
parent b430f1c572
commit c33d282a5c
4 changed files with 17 additions and 17 deletions
@@ -118,7 +118,7 @@ namespace mROA.Implementation.Frontend
else else
{ {
tokenSource.Cancel(); tokenSource.Cancel();
var request = defaultRequest.Result; var request = eventRequest.Result;
_executeModule.Execute(request, _contextRepository, _representationModule); _executeModule.Execute(request, _contextRepository, _representationModule);
} }
} }
@@ -9,13 +9,13 @@ namespace mROA.Implementation
{ {
public class NextGenerationInteractionModule : INextGenerationInteractionModule public class NextGenerationInteractionModule : INextGenerationInteractionModule
{ {
private ISerializationToolkit? _serialization;
public int ConnectionId { get; private set; }
public Stream? BaseStream { get; set; }
private Task<NetworkMessage>? _currentReceiving;
private const int BufferSize = ushort.MaxValue; private const int BufferSize = ushort.MaxValue;
private readonly Memory<byte> _buffer = new byte[BufferSize]; private readonly Memory<byte> _buffer = new byte[BufferSize];
private readonly List<NetworkMessage> _messageBuffer = new(128); private readonly List<NetworkMessage> _messageBuffer = new(128);
private Task<NetworkMessage>? _currentReceiving;
private ISerializationToolkit? _serialization;
public int ConnectionId { get; private set; }
public Stream? BaseStream { get; set; }
public void Inject<T>(T dependency) public void Inject<T>(T dependency)
@@ -36,7 +36,6 @@ namespace mROA.Implementation
if (_currentReceiving != null) return _currentReceiving; if (_currentReceiving != null) return _currentReceiving;
_currentReceiving = Task.Run(async () => await GetNextMessage()); _currentReceiving = Task.Run(async () => await GetNextMessage());
return _currentReceiving; return _currentReceiving;
} }
public async Task PostMessage(NetworkMessage message) public async Task PostMessage(NetworkMessage message)
@@ -62,6 +61,7 @@ namespace mROA.Implementation
} }
public NetworkMessage[] UnhandledMessages => _messageBuffer.ToArray(); public NetworkMessage[] UnhandledMessages => _messageBuffer.ToArray();
public NetworkMessage? FirstByFilter(Predicate<NetworkMessage> predicate) public NetworkMessage? FirstByFilter(Predicate<NetworkMessage> predicate)
{ {
return _messageBuffer.FirstOrDefault(m => predicate(m)); return _messageBuffer.FirstOrDefault(m => predicate(m));
@@ -89,7 +89,7 @@ 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.Id} - {message.SchemaId}");
TransmissionConfig.TotalTransmittedBytes += len; TransmissionConfig.TotalTransmittedBytes += len;
Console.WriteLine($"Total recieced bytes are {TransmissionConfig.TotalTransmittedBytes}"); Console.WriteLine($"Total recieced bytes are {TransmissionConfig.TotalTransmittedBytes}");
#endif #endif
+1 -1
View File
@@ -91,7 +91,7 @@ namespace mROA.Implementation
if (_serialization == null) if (_serialization == null)
throw new NullReferenceException("Serialization toolkit is not initialized"); throw new NullReferenceException("Serialization toolkit is not initialized");
#if TRACE #if TRACE
Console.WriteLine($"Posting message: {id} - {messageType}"); Console.WriteLine($"Posting message: {id} - {messageType} to {Id}");
#endif #endif
var serialized = _serialization.Serialize(payload, payloadType); var serialized = _serialization.Serialize(payload, payloadType);
+1 -1
View File
@@ -21,7 +21,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants></DefineConstants> <DefineConstants>TRACE;</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>