diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f16143..5f4d06b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [Unreleased] (1.8.61) +## [1.8.61] - 2026-03-01 ### Changed - Update to [TDLib v1.8.61](https://github.com/ForNeVeR/tdlib-versioned/releases/tag/tdlib%2Fv1.8.61). +### Added +- New constructor for `TdClient` with configurable receive timeout. Thanks to @bielu! + ## [1.8.60] - 2026-01-10 ### Changed - Update to [TDLib v1.8.60](https://github.com/ForNeVeR/tdlib-versioned/releases/tag/tdlib%2Fv1.8.60). @@ -143,4 +146,5 @@ Initial release to support TDLib pre-1.2. [1.8.58]: https://github.com/egramtel/tdsharp/compare/v1.8.56.1...v1.8.58 [1.8.59]: https://github.com/egramtel/tdsharp/compare/v1.8.58...v1.8.59 [1.8.60]: https://github.com/egramtel/tdsharp/compare/v1.8.59...v1.8.60 -[Unreleased]: https://github.com/egramtel/tdsharp/compare/v1.8.60...HEAD +[1.8.61]: https://github.com/egramtel/tdsharp/compare/v1.8.60...v1.8.61 +[Unreleased]: https://github.com/egramtel/tdsharp/compare/v1.8.61...HEAD diff --git a/TdLib/Bindings/Receiver.cs b/TdLib/Bindings/Receiver.cs index 83a22ebf..bae63d47 100644 --- a/TdLib/Bindings/Receiver.cs +++ b/TdLib/Bindings/Receiver.cs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 tdsharp contributors +// SPDX-FileCopyrightText: 2024-2026 tdsharp contributors // // SPDX-License-Identifier: MIT @@ -13,7 +13,7 @@ internal class Receiver : IDisposable { private readonly Converter _converter; private readonly TdJsonClient _tdJsonClient; - private readonly double _receiverTimeOut; + private readonly double _receiverTimeOutSeconds; private readonly CancellationTokenSource _cts = new CancellationTokenSource(); private readonly ManualResetEventSlim _stopped = new ManualResetEventSlim(false); @@ -22,11 +22,11 @@ internal class Receiver : IDisposable internal event EventHandler AuthorizationStateChanged; internal event EventHandler ExceptionThrown; - internal Receiver(TdJsonClient tdJsonClient, double receiverTimeOut) + internal Receiver(TdJsonClient tdJsonClient, TimeSpan receiverTimeOut) { _converter = new Converter(); _tdJsonClient = tdJsonClient; - _receiverTimeOut = receiverTimeOut; + _receiverTimeOutSeconds = receiverTimeOut.TotalSeconds; } internal void Start() @@ -51,7 +51,7 @@ private void ProcessEvents() var ct = _cts.Token; while (!ct.IsCancellationRequested) { - var data = _tdJsonClient.Receive(_receiverTimeOut); + var data = _tdJsonClient.Receive(_receiverTimeOutSeconds); if (!string.IsNullOrEmpty(data)) { diff --git a/TdLib/TdClient.cs b/TdLib/TdClient.cs index f60e28af..b1d2bc6b 100644 --- a/TdLib/TdClient.cs +++ b/TdLib/TdClient.cs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 tdsharp contributors +// SPDX-FileCopyrightText: 2024-2026 tdsharp contributors // // SPDX-License-Identifier: MIT @@ -27,11 +27,14 @@ public class TdClient : TdApi.Client, IDisposable public TdClient() : this(Interop.AutoDetectBindings()) {} - public TdClient(ITdLibBindings bindings): this( bindings, 0.1 ) + /// Bidings for the client to call functions of TDLib. + public TdClient(ITdLibBindings bindings): this(bindings, TimeSpan.FromSeconds(0.1)) { - } - public TdClient(ITdLibBindings bindings, double receiverTimeOut) + + /// Bidings for the client to call functions of TDLib. + /// Timeout for td_json_client_receive. + public TdClient(ITdLibBindings bindings, TimeSpan receiverTimeOut) { _tdJsonClient = new TdJsonClient(bindings); diff --git a/TdLib/TdJsonClient.cs b/TdLib/TdJsonClient.cs index 1c5932be..08495a81 100644 --- a/TdLib/TdJsonClient.cs +++ b/TdLib/TdJsonClient.cs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 tdsharp contributors +// SPDX-FileCopyrightText: 2024-2026 tdsharp contributors // // SPDX-License-Identifier: MIT @@ -48,6 +48,7 @@ public void Send(string data) /// /// Receive one JSON string from TDLib /// + /// Timeout in seconds. public string Receive(double timeout) { if (_handle == IntPtr.Zero) diff --git a/global.json b/global.json index 345f67e3..2da9069d 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "9.0.306" + "version": "9.0.306", + "rollForward": "major" } } diff --git a/global.json.license b/global.json.license index cd1d78a8..40ac8020 100644 --- a/global.json.license +++ b/global.json.license @@ -1,3 +1,3 @@ -SPDX-FileCopyrightText: 2025 Friedrich von Never +SPDX-FileCopyrightText: 2025-2026 Friedrich von Never SPDX-License-Identifier: MIT