Implement after_msg_id back

This commit is contained in:
Lonami Exo 2018-10-19 16:53:50 +02:00
parent 9dc4009152
commit 0686ec4440
3 changed files with 8 additions and 9 deletions

View File

@ -71,9 +71,9 @@ class MessagePacker:
size += len(state.data) + TLMessage.SIZE_OVERHEAD
if size <= MessageContainer.MAXIMUM_SIZE:
# TODO Implement back using after_id
state.msg_id = self._state.write_data_as_message(
buffer, state.data, isinstance(state.request, TLRequest)
buffer, state.data, isinstance(state.request, TLRequest),
after_id=state.after.msg_id if state.after else None
)
batch.append(state)
__log__.debug('Assigned msg_id = %d to %s (%x)',

View File

@ -161,15 +161,13 @@ class MTProtoSender:
else:
states = []
futures = []
state = None
for req in request:
state = RequestState(req, self._loop)
state = RequestState(req, self._loop, after=ordered and state)
states.append(state)
futures.append(state.future)
if ordered:
self._send_queue.append(states)
else:
self._send_queue.extend(states)
self._send_queue.extend(states)
return futures
@property

View File

@ -8,11 +8,12 @@ class RequestState:
it belongs to, the request itself, the request as bytes, and the future
result that will eventually be resolved.
"""
__slots__ = ('container_id', 'msg_id', 'request', 'data', 'future')
__slots__ = ('container_id', 'msg_id', 'request', 'data', 'future', 'after')
def __init__(self, request, loop):
def __init__(self, request, loop, after=None):
self.container_id = None
self.msg_id = None
self.request = request
self.data = bytes(request)
self.future = asyncio.Future(loop=loop)
self.after = after