Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
10 changes: 5 additions & 5 deletions TdLib/Bindings/Receiver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 tdsharp contributors <https://github.com/egramtel/tdsharp>
// SPDX-FileCopyrightText: 2024-2026 tdsharp contributors <https://github.com/egramtel/tdsharp>
//
// SPDX-License-Identifier: MIT

Expand All @@ -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);
Expand All @@ -22,11 +22,11 @@ internal class Receiver : IDisposable
internal event EventHandler<TdApi.AuthorizationState> AuthorizationStateChanged;
internal event EventHandler<Exception> 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()
Expand All @@ -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))
{
Expand Down
11 changes: 7 additions & 4 deletions TdLib/TdClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 tdsharp contributors <https://github.com/egramtel/tdsharp>
// SPDX-FileCopyrightText: 2024-2026 tdsharp contributors <https://github.com/egramtel/tdsharp>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -27,11 +27,14 @@ public class TdClient : TdApi.Client, IDisposable

public TdClient() : this(Interop.AutoDetectBindings()) {}

public TdClient(ITdLibBindings bindings): this( bindings, 0.1 )
/// <param name="bindings">Bidings for the client to call functions of TDLib.</param>
public TdClient(ITdLibBindings bindings): this(bindings, TimeSpan.FromSeconds(0.1))
{

}
public TdClient(ITdLibBindings bindings, double receiverTimeOut)

/// <param name="bindings">Bidings for the client to call functions of TDLib.</param>
/// <param name="receiverTimeOut">Timeout for <c>td_json_client_receive</c>.</param>
public TdClient(ITdLibBindings bindings, TimeSpan receiverTimeOut)
{
_tdJsonClient = new TdJsonClient(bindings);

Expand Down
3 changes: 2 additions & 1 deletion TdLib/TdJsonClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 tdsharp contributors <https://github.com/egramtel/tdsharp>
// SPDX-FileCopyrightText: 2024-2026 tdsharp contributors <https://github.com/egramtel/tdsharp>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -48,6 +48,7 @@ public void Send(string data)
/// <summary>
/// Receive one JSON string from TDLib
/// </summary>
/// <param name="timeout">Timeout in seconds.</param>
public string Receive(double timeout)
{
if (_handle == IntPtr.Zero)
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "9.0.306"
"version": "9.0.306",
"rollForward": "major"
}
}
2 changes: 1 addition & 1 deletion global.json.license
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2025 Friedrich von Never <friedrich@fornever.me>
SPDX-FileCopyrightText: 2025-2026 Friedrich von Never <friedrich@fornever.me>

SPDX-License-Identifier: MIT
Loading