/// <summary> /// Creates a new <see cref="LiteClient"/> instance with the given <see cref="LiteClientOptions"/>. /// </summary> /// <param name="options">A client configuration options.</param> /// <param name="serviceProvider">Service provider to use.</param> public LiteClient(LiteClientOptions options, IServiceProvider serviceProvider = null !) { if (options is null) { throw new ArgumentNullException(nameof(options)); } Id = Guid.NewGuid(); Options = options; _serviceProvider = serviceProvider; Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _connector = new LiteClientConnector(Socket, Options.Host, Options.Port); _sender = new LiteSender(this); _receiver = new LiteClientReceiver(options.PacketProcessor, options.ReceiveStrategy, options.BufferSize); _receiver.Error += (s, e) => OnError(e); if (_serviceProvider is not null) { _logger = _serviceProvider.GetService <ILogger <LiteClient> >(); } }
/// <summary> /// Creates a new <see cref="LiteServerUser"/> instance. /// </summary> public LiteServerUser() { _sender = new LiteSender(this); }