2020-02-11 17:44:06 -05:00
|
|
|
|
using IW4MAdmin.Application.RCon;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using System.Text;
|
2020-11-11 18:31:26 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-02-11 17:44:06 -05:00
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Application.Factories
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// implementation of IRConConnectionFactory
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal class RConConnectionFactory : IRConConnectionFactory
|
|
|
|
|
{
|
|
|
|
|
private static readonly Encoding gameEncoding = Encoding.GetEncoding("windows-1252");
|
2020-11-11 18:31:26 -05:00
|
|
|
|
private readonly ILogger<RConConnection> _logger;
|
2020-02-11 17:44:06 -05:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base constructor
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger"></param>
|
2020-11-11 18:31:26 -05:00
|
|
|
|
public RConConnectionFactory(ILogger<RConConnection> logger)
|
2020-02-11 17:44:06 -05:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// creates a new rcon connection instance
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ipAddress">ip address of the server</param>
|
|
|
|
|
/// <param name="port">port of the server</param>
|
|
|
|
|
/// <param name="password">rcon password of the server</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public IRConConnection CreateConnection(string ipAddress, int port, string password)
|
|
|
|
|
{
|
|
|
|
|
return new RConConnection(ipAddress, port, password, _logger, gameEncoding);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|