что то неожиданно сломалось после рефакторинга
This commit is contained in:
1 parent
33ca84fb0d
commit
4a95cd84c1
34 files changed
+154
-185
No files matched your search
@@ -2,21 +2,28 @@ using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using mROA.Abstract;
|
||||
|
||||
namespace mROA.Implementation;
|
||||
namespace mROA.Implementation.Frontend;
|
||||
|
||||
public class NetworkFrontendBridge : IFrontendBridge
|
||||
public class NetworkFrontendBridge(IPEndPoint ipEndPoint) : IFrontendBridge
|
||||
{
|
||||
private TcpClient _tcpClient;
|
||||
public NetworkFrontendBridge(IPEndPoint serverEndPoint)
|
||||
{
|
||||
_tcpClient = new TcpClient();
|
||||
_tcpClient.Connect(serverEndPoint);
|
||||
}
|
||||
private readonly TcpClient _tcpClient = new();
|
||||
private StreamBasedFrontendInteractionModule? _interactionModule;
|
||||
|
||||
public void Inject<T>(T dependency)
|
||||
{
|
||||
if (dependency is StreamBasedFrontendInteractionModule interactionModule)
|
||||
{
|
||||
interactionModule.ServerStream = _tcpClient.GetStream();
|
||||
_interactionModule = interactionModule;
|
||||
}
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
_tcpClient.Connect(ipEndPoint);
|
||||
if (_interactionModule is null)
|
||||
{
|
||||
throw new Exception("Interaction module was not injected");
|
||||
}
|
||||
_interactionModule.ServerStream = _tcpClient.GetStream();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user