mtproto-core icon indicating copy to clipboard operation
mtproto-core copied to clipboard

Only subscribe to updates when a handler is attached.

Open happymaskterriblefate opened this issue 3 years ago • 1 comments

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 avatar May 27 '21 13:05 happymaskterriblefate

Friendly bump on this :)

happymaskterriblefate avatar Jul 24 '21 16:07 happymaskterriblefate