/// <summary> /// Initialize TP Socket if it isn't already. /// </summary> private void InitializeConnection() { if (_tpsocket == null || !_tpsocket.Connected) { var ipe = new IPEndPoint(IPAddress.Parse(_options.CurrentValue.ServerIp), _options.CurrentValue.ServerPort); _tpsocket = new TPSocket(ipe.AddressFamily); _tpsocket.Connect(ipe); } }
/// <summary> /// Constructor /// </summary> /// <param name="options">Configured TP Options</param> /// <param name="socket">The TP Socket Object</param> /// <param name="processQueueingService">THe Process Queue Service</param> /// <param name="cancellationToken">Cancellation Token</param> public TPClient(IOptionsMonitor <TouchPortalApiOptions> options, ITPSocket socket, IProcessQueueingService processQueueingService) { _options = options ?? throw new ArgumentNullException(nameof(options)); _tpsocket = socket ?? throw new ArgumentNullException(nameof(socket)); _processQueueingService = processQueueingService ?? throw new ArgumentNullException(nameof(processQueueingService)); // Add this somewhere in your project, most likely in Startup.cs JsonConvert.DefaultSettings = () => new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; InitializeConnection(); }