билдится на старом дотнете
This commit is contained in:
1 parent
5af9408a9a
commit
50fd3e7b73
69 files changed
+1990
-1675
No files matched your search
@@ -1,43 +1,51 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation.Frontend;
|
||||
|
||||
public class NetworkFrontendBridge(IPEndPoint ipEndPoint) : IFrontendBridge
|
||||
namespace mROA.Implementation.Frontend
|
||||
{
|
||||
private readonly TcpClient _tcpClient = new();
|
||||
private NextGenerationInteractionModule? _interactionModule;
|
||||
private ISerializationToolkit? _serialization;
|
||||
|
||||
public void Inject<T>(T dependency)
|
||||
public class NetworkFrontendBridge : IFrontendBridge
|
||||
{
|
||||
switch (dependency)
|
||||
private readonly TcpClient _tcpClient = new();
|
||||
private NextGenerationInteractionModule? _interactionModule;
|
||||
private ISerializationToolkit? _serialization;
|
||||
private readonly IPEndPoint _ipEndPoint;
|
||||
|
||||
public NetworkFrontendBridge(IPEndPoint ipEndPoint)
|
||||
{
|
||||
case NextGenerationInteractionModule interactionModule:
|
||||
_interactionModule = interactionModule;
|
||||
break;
|
||||
case ISerializationToolkit toolkit:
|
||||
_serialization = toolkit;
|
||||
break;
|
||||
_ipEndPoint = ipEndPoint;
|
||||
}
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
if (_interactionModule is null)
|
||||
throw new Exception("Interaction module was not injected");
|
||||
if (_serialization == null)
|
||||
throw new NullReferenceException("Serialization toolkit is not initialized");
|
||||
public void Inject<T>(T dependency)
|
||||
{
|
||||
switch (dependency)
|
||||
{
|
||||
case NextGenerationInteractionModule interactionModule:
|
||||
_interactionModule = interactionModule;
|
||||
break;
|
||||
case ISerializationToolkit toolkit:
|
||||
_serialization = toolkit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
if (_interactionModule is null)
|
||||
throw new Exception("Interaction module was not injected");
|
||||
if (_serialization == null)
|
||||
throw new NullReferenceException("Serialization toolkit is not initialized");
|
||||
|
||||
_tcpClient.Connect(ipEndPoint);
|
||||
_interactionModule.BaseStream = _tcpClient.GetStream();
|
||||
var welcomeMessage = _interactionModule.GetNextMessageReceiving().GetAwaiter().GetResult();
|
||||
if (welcomeMessage.SchemaId != MessageType.IdAssigning)
|
||||
{
|
||||
throw new Exception($"Incorrect message type. Must be IdAssigning, current : {welcomeMessage.SchemaId.ToString()}");
|
||||
}
|
||||
_tcpClient.Connect(_ipEndPoint);
|
||||
_interactionModule.BaseStream = _tcpClient.GetStream();
|
||||
var welcomeMessage = _interactionModule.GetNextMessageReceiving().GetAwaiter().GetResult();
|
||||
if (welcomeMessage.SchemaId != MessageType.IdAssigning)
|
||||
{
|
||||
throw new Exception($"Incorrect message type. Must be IdAssigning, current : {welcomeMessage.SchemaId.ToString()}");
|
||||
}
|
||||
|
||||
TransmissionConfig.OwnershipRepository = new StaticOwnershipRepository(_serialization.Deserialize<IdAssingnment>(welcomeMessage.Data)!.Id);
|
||||
TransmissionConfig.OwnershipRepository = new StaticOwnershipRepository(_serialization.Deserialize<IdAssingnment>(welcomeMessage.Data)!.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user