Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant