Skip to content

How to make it so that tdlib operates like a daemon? #139

Closed

Description

@bangonkali

Is there any sample in C# such that tdlib operates like a daemon and continues to update db.sqlite with new data as updated information is received?

Somehow this example from tdlib can do client_manager_->receive(10).

  void loop() {
    while (true) {
      if (need_restart_) {
        restart();
      } else if (!are_authorized_) {
        process_response(client_manager_->receive(10));
      } else {

Is there a way to mirror this Using strongly typed APIs?

Or do I have to use the untyped version to be able to make some sort of daemon approach?

Activity

  1. ForNeVeR commented on Aug 28, 2022

    @ForNeVeR
    Member

    I don't think we support the ClientManager, yet. This is out of scope of "normal" MTProto API, since this is just a C++ class (not sure it has C wrappers around it to be available for P/Invoke).

  2. ForNeVeR commented on Aug 28, 2022

    @ForNeVeR
    Member

    But I can't see how it relates to your daemon question. What do you mean by that? AFAIK, tdlib just normally updates its database during execution; there's no special "daemon approach" or something like that.

  3. bangonkali commented on Aug 29, 2022

    @bangonkali
    Author

    Hi @ForNeVeR ,

    But I can't see how it relates to your daemon question. What do you mean by that?

    I have created a simple application in CLI however I have been left in a request and response model. I would like to know if it's possible to have a concurrent approach to request & response wherein the CLI will not shutdown but always receive updates.

    Can you recommend a simple pattern for this?

    For now when my cli app for example lists chats and messages in chats, the application stops after completion. What I'm looking for is to keep tdlib awake and keep on receiving updates and my cli app can then just listen to the updates indefinitely.

    I may be missing something fundamental here though.

    I will look in to ClientManager as it seems you may be suggesting something here but I don't understand it full yet at the moment. 😅

  4. ForNeVeR commented on Aug 29, 2022

    @ForNeVeR
    Member

    The usual pattern for daemon-like code in C# is to use a Generic Host, that has no relation to tdlib's ClientManager whatsoever.

  5. locked and limited conversation to collaborators on Aug 29, 2022
  6. converted this issue into a discussion #140 on Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions