Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Only subscribe to updates when a handler is attached. #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

happymaskterriblefate
Copy link

This PR updates the RPC open transport method to only subscribe to telegram updates if an update handler is attached to the context.updates event emitter.

Per Telegram's docs for file transfers:

It is recommended that large queries (upload.getFile, upload.saveFilePart, upload.getWebFile) be handled through a separate session and a separate connection, in which no methods other than these should be executed. If this is done, then data transfer will cause less interference with getting updates and other method calls.

Currently, mtproto-core automatically subscribes to updates when you create an instance of MTProto. By listening to the newListeners handler on an EventEmitter, we can optionally subscribe to events only when the client cares about them. This will allow users to create two instances of the MTProto client -- one specifically for file transfers that does not listen for telegram updates, and another for everything else.

@happymaskterriblefate
Copy link
Author

Friendly bump on this :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant