Additional preprocessor changes
This commit is contained in:
@@ -54,7 +54,7 @@ class Program
|
|||||||
DemoCheck.CreatingPrinter = true;
|
DemoCheck.CreatingPrinter = true;
|
||||||
disposingPrinter.OnPrint += (_, _) =>
|
disposingPrinter.OnPrint += (_, _) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("New page creater. Called from event!!!");
|
Console.WriteLine("New page created. Called from event!!!");
|
||||||
DemoCheck.EventCallback = true;
|
DemoCheck.EventCallback = true;
|
||||||
};
|
};
|
||||||
Console.WriteLine("Printer created");
|
Console.WriteLine("Printer created");
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ namespace mROA.Implementation
|
|||||||
private bool _isActive = true;
|
private bool _isActive = true;
|
||||||
private TaskCompletionSource<Stream> _reconnection;
|
private TaskCompletionSource<Stream> _reconnection;
|
||||||
public IEndPointContext Context { get; set; }
|
public IEndPointContext Context { get; set; }
|
||||||
|
|
||||||
public ChannelInteractionModule()
|
public ChannelInteractionModule()
|
||||||
{
|
{
|
||||||
ReceiveChanel = Channel.CreateUnbounded<NetworkMessageHeader>(new UnboundedChannelOptions
|
ReceiveChanel = Channel.CreateUnbounded<NetworkMessageHeader>(new UnboundedChannelOptions
|
||||||
@@ -100,7 +101,9 @@ namespace mROA.Implementation
|
|||||||
{
|
{
|
||||||
if (withError)
|
if (withError)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Post again");
|
Console.WriteLine("Post again");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await PostMessageInternal(messageHeader))
|
if (await PostMessageInternal(messageHeader))
|
||||||
@@ -131,19 +134,24 @@ namespace mROA.Implementation
|
|||||||
await PostMessageAsync(
|
await PostMessageAsync(
|
||||||
new NetworkMessageHeader(_serialization!, new ClientRecovery(Math.Abs(ConnectionId)), Context));
|
new NetworkMessageHeader(_serialization!, new ClientRecovery(Math.Abs(ConnectionId)), Context));
|
||||||
var ping = await ReceiveChanel.Reader.ReadAsync();
|
var ping = await ReceiveChanel.Reader.ReadAsync();
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine($"Ping received {ping.Id}");
|
Console.WriteLine($"Ping received {ping.Id}");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _trustedWriter.WriteAsync(new NetworkMessageHeader());
|
await _trustedWriter.WriteAsync(new NetworkMessageHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Setting result for reconnection");
|
Console.WriteLine("Setting result for reconnection");
|
||||||
|
#endif
|
||||||
var setting = _reconnection.TrySetResult(null);
|
var setting = _reconnection.TrySetResult(null);
|
||||||
// _isInReconnectionState = false;
|
// _isInReconnectionState = false;
|
||||||
_isConnected = true;
|
_isConnected = true;
|
||||||
|
#if true
|
||||||
Console.WriteLine($"Set result for reconnection {setting}");
|
Console.WriteLine($"Set result for reconnection {setting}");
|
||||||
|
#endif
|
||||||
_reconnection = new TaskCompletionSource<Stream>();
|
_reconnection = new TaskCompletionSource<Stream>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,29 +159,40 @@ namespace mROA.Implementation
|
|||||||
{
|
{
|
||||||
//TODO переделать реконнект
|
//TODO переделать реконнект
|
||||||
|
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Staring recovery from {0}", source);
|
Console.WriteLine("Staring recovery from {0}", source);
|
||||||
|
#endif
|
||||||
|
|
||||||
lock (_reconnection)
|
lock (_reconnection)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Got lock from {0}", source);
|
Console.WriteLine("Got lock from {0}", source);
|
||||||
|
|
||||||
Console.WriteLine("Call OnDisconnected from {0}", source);
|
Console.WriteLine("Call OnDisconnected from {0}", source);
|
||||||
|
#endif
|
||||||
OnDisconnected?.Invoke(ConnectionId);
|
OnDisconnected?.Invoke(ConnectionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Waiting for reconnect from {0}", source);
|
Console.WriteLine("Waiting for reconnect from {0}", source);
|
||||||
|
#endif
|
||||||
if (!_reconnection.Task.IsCompleted && !_isConnected)
|
if (!_reconnection.Task.IsCompleted && !_isConnected)
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Current connection state {0} from {1}", _isConnected, source);
|
Console.WriteLine("Current connection state {0} from {1}", _isConnected, source);
|
||||||
|
#endif
|
||||||
await _reconnection.Task;
|
await _reconnection.Task;
|
||||||
}
|
}
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Reconnect finished from {0}", source);
|
Console.WriteLine("Reconnect finished from {0}", source);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
#if TRACE
|
||||||
Console.WriteLine("Interaction module disposed");
|
Console.WriteLine("Interaction module disposed");
|
||||||
|
#endif
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
if (_currentReceiving is { IsCompleted: true })
|
if (_currentReceiving is { IsCompleted: true })
|
||||||
{
|
{
|
||||||
@@ -191,7 +210,8 @@ namespace mROA.Implementation
|
|||||||
private IEndPointContext Context;
|
private IEndPointContext Context;
|
||||||
public readonly int Id = new Random().Next();
|
public readonly int Id = new Random().Next();
|
||||||
|
|
||||||
public StreamExtractor(Stream ioStream, IContextualSerializationToolKit serializationToolkit, IEndPointContext context)
|
public StreamExtractor(Stream ioStream, IContextualSerializationToolKit serializationToolkit,
|
||||||
|
IEndPointContext context)
|
||||||
{
|
{
|
||||||
_ioStream = ioStream;
|
_ioStream = ioStream;
|
||||||
_serializationToolkit = serializationToolkit;
|
_serializationToolkit = serializationToolkit;
|
||||||
@@ -250,7 +270,6 @@ namespace mROA.Implementation
|
|||||||
|
|
||||||
public async Task Send(NetworkMessageHeader message, CancellationToken token = default)
|
public async Task Send(NetworkMessageHeader message, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var rawMessage = _serializationToolkit.Serialize(message, Context);
|
var rawMessage = _serializationToolkit.Serialize(message, Context);
|
||||||
|
|||||||
Reference in New Issue
Block a user