LJClientPoolService.cs 947 B

123456789101112131415161718192021222324252627282930313233
  1. using LJLib.Client;
  2. using LJLib.Net.SPI.Client;
  3. using LJProxy.Settings;
  4. using Microsoft.Extensions.Options;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. namespace LJProxy.Services
  10. {
  11. public class LJClientPoolService
  12. {
  13. private AppSettings _appSettingModel;
  14. private ILJClient _pool;
  15. public LJClientPoolService(IOptions<AppSettings> appSettingModel)
  16. {
  17. _appSettingModel = appSettingModel.Value;
  18. var url = _appSettingModel.L1SvrUrl;
  19. var urlArr = url.Split(':');
  20. var ip = urlArr[0];
  21. var port = urlArr[1];
  22. var creator = new DirectP1ClientCreator(ip, Convert.ToInt32(port));
  23. _pool = new LJClientPool(creator, _appSettingModel.ThreadSize);
  24. }
  25. public ILJClient Pool
  26. {
  27. get { return _pool; }
  28. }
  29. }
  30. }