Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

75 Commits

Repository files navigation

TDLib

.NET bindings for TDLib (Telegram Database Library): https://github.com/tdlib/td

  • Generated API bindings
  • .NET Core and .NET Standard support

Installation

Install via NuGet: TDLib

NuGet

Dependencies

You're recommended to use precompiled version of TDLib native artifacts from NuGet: TDLib.Native

NuGet

Note that tdlib.native is not a dependency of TDLib, so you may choose to build the binaries yourself and provide them at the runtime.

To do that, build TDLib and put the compiled library into your project's output directory

  • tdjson.dll (Windows) (optionally accompanied by other DLL files from the build directory if you want to bundle OpenSSL and ZLib dependencies as well)
  • libtdjson.dylib (MacOS)
  • libtdjson.so (Linux)

Using json client

TdJsonClient is a wrapper around native JSON APIs. Use it to send/receive data as strings.

usingTdLib;varjson="";// json datadoubletimeout=1.0;// 1 secondusing(varjsonClient=newTdJsonClient()){jsonClient.Send(json);// send requestvarresult=jsonClient.Receive(timeout);// receive response}

Using strongly typed APIs

This library contains generated classes for objects and functions. JSON serialization and deserialization is handled automatically. Use TdClient to asynchronously execute functions.

usingTdLib;using(varclient=newTdClient()){try{// asynchronously execute functionTdApi.Okok=awaitclient.ExecuteAsync(newTdApi.SetAuthenticationPhoneNumber{PhoneNumber=phoneNumber});// or use extension methodok=awaitclient.SetAuthenticationPhoneNumberAsync(phoneNumber);// do something...}catch(ErrorExceptione){TdApi.Errorerror=e.Error;// handle error...}}

Overriding native bindings

By default, TdSharp will try to detect the platform and use the corresponding bindings to native td library. In case you want to override it (e.g. for Xamarin), create a custom implementation of ITdLibBindings (which corresponds to native library interface used by TdSharp) and pass it to TdClient constructor.

About

Userizyon C# Client

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages