промежуточная фиксация рефакторинга
parent
fba480eaae
commit
78f9f6c398
|
@ -1,4 +1,5 @@
|
|||
using Sphagnum.Common.Infrastructure.Contracts;
|
||||
using Sphagnum.Common.Infrastructure.Services;
|
||||
using Sphagnum.Common.Messaging.Contracts;
|
||||
using Sphagnum.Common.Messaging.Contracts.Messages;
|
||||
using Sphagnum.Common.Messaging.Utils;
|
||||
|
@ -14,7 +15,7 @@ namespace Sphagnum.Client
|
|||
private readonly IConnection _connection;
|
||||
private readonly Channel<byte[]> _commonMessagesChannel = Channel.CreateUnbounded<byte[]>();
|
||||
private readonly CancellationTokenSource _cts = new CancellationTokenSource();
|
||||
public ClientDefault(IConnectionFactory factory)
|
||||
public ClientDefault(ConnectionFactory factory)
|
||||
{
|
||||
_connection = factory.CreateConnection().Result;
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
using Sphagnum.Common.Old.Contracts.Login;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sphagnum.Common.Infrastructure.Contracts
|
||||
{
|
||||
public interface IConnectionFactory
|
||||
{
|
||||
public int Port { get; }
|
||||
public string Hostname { get; }
|
||||
public string Login { get; }
|
||||
public string Password { get; }
|
||||
public UserRights UserRights { get; set; }
|
||||
internal Task<IConnection> CreateConnection(bool connected = true);
|
||||
}
|
||||
}
|
|
@ -5,14 +5,14 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace Sphagnum.Common.Infrastructure.Services
|
||||
{
|
||||
public class ConnectionFactory : IConnectionFactory
|
||||
public class ConnectionFactory
|
||||
{
|
||||
public int Port { get; set; }
|
||||
public string Hostname { get; set; } = string.Empty;
|
||||
public string Login { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
public UserRights UserRights { get; set; }
|
||||
async Task<IConnection> IConnectionFactory.CreateConnection(bool connected = true)
|
||||
internal virtual async Task<IConnection> CreateConnection(bool connected = true)
|
||||
{
|
||||
var conn = new SocketConnection(new Socket(SocketType.Stream, ProtocolType.Tcp));
|
||||
if (connected)
|
||||
|
|
Loading…
Reference in New Issue