Commit Graph

91 Commits

Author SHA1 Message Date
Lonami Exo
bff2e6981e Fix ._pop_request_of_type failing on not-found requests 2017-10-12 18:03:10 +02:00
Lonami Exo
7bb7cb039f Fix handle RpcResult not always returning a bool 2017-10-12 17:58:37 +02:00
Lonami Exo
0c1170ee61 Replace hardcoded reads with TLObject's .read() 2017-10-12 16:40:59 +02:00
Lonami Exo
301da16f29 Fix pong response not reading all data from the buffer 2017-10-11 21:09:09 +02:00
Lonami Exo
9d394ab18b Send MsgsAck in the same container along with the requests 2017-10-06 11:36:39 +02:00
Lonami Exo
e717256937 Always use session ip address and port when connecting 2017-10-01 19:26:20 +02:00
Lonami Exo
36dabc4928 Process entities from the MtProtoSender instead TelegramBareClient
This way, update objects will also be processed when they occur.
2017-10-01 16:02:29 +02:00
Lonami Exo
0a567fcd7c Make creating a new sender cleaner 2017-09-30 12:08:06 +02:00
Lonami Exo
5da300ca84 Make MtProtoSender not thread-safe
Rationale: a new connection should be spawned if one desires to
send and receive requests in parallel, which would otherwise cause
one of either threads to lock.
2017-09-30 11:50:11 +02:00
Lonami Exo
56103845de Fix LogOutRequest consuming all retries (#270) 2017-09-29 13:58:15 +02:00
Lonami Exo
afc4bd9cab Rename constructor/subclass_of_id to upper case, keep only static 2017-09-29 13:11:33 +02:00
Lonami Exo
cc337328c6 Rename handmade Message class to TLMessage to avoid confusion 2017-09-28 11:59:24 +02:00
Lonami Exo
833aeb86eb Fix auth_key is unsigned 2017-09-27 21:04:52 +02:00
Lonami Exo
bd3dd371a2 Create a proper Message class (msg_id, seqno, body; only .to_bytes()) 2017-09-27 21:01:20 +02:00
Lonami Exo
6df9fc558e Create and use a new GzipPacked class, also when sending 2017-09-27 13:46:53 +02:00
Lonami Exo
efca981312 Fix adding a request twice (or container) to ._pending_receive 2017-09-27 13:26:35 +02:00
Lonami Exo
b83cd98ba0 Replace TLObject.on_send with the new .to_bytes()
This also replaces some int.to_bytes() calls with a faster
struct.pack (up to x4 faster). This approach is also around
x3 faster than creating a BinaryWriter just to serialize a
TLObject as bytes.
2017-09-26 14:36:02 +02:00
Lonami Exo
f233110732 Allow sending several requests at once through new MessageContainer 2017-09-25 20:52:27 +02:00
Lonami Exo
4a8e5c865a Detect BrokenAuthKeyError on MtProtoSender._decode_msg 2017-09-22 13:32:00 +02:00
Lonami Exo
ffadcd029f Save the session much less often (doable because 151e162) 2017-09-21 19:12:46 +02:00
Lonami Exo
2b2da843a1 Create a Connection only once and avoid no-op if was "connected" 2017-09-21 13:44:22 +02:00
Lonami Exo
2a3e5e5ed2 Handle BufferError's more gracefully 2017-09-17 19:39:41 +02:00
Lonami Exo
12a39873f1 Workaround msg_seqno too low/high (closes #95) 2017-09-14 11:50:38 +02:00
Lonami Exo
a2fdd4b196 Ignore InvalidChecksumError's 2017-09-11 11:04:19 +02:00
Lonami Exo
25bbb20b0c Use RLocks properly on MtProtoSender (only needed on net IO) 2017-09-07 21:32:46 +02:00
Lonami Exo
d4f36162cd Create and use UpdateState to .process() unhandled TLObjects 2017-09-07 18:49:08 +02:00
Lonami Exo
15fd5390ae Optimize imports 2017-09-04 17:18:33 +02:00
Lonami Exo
97cab7347b Make lint happier 2017-09-04 17:10:04 +02:00
Lonami Exo
f8f389c850 Fix ack requests removing pending requests when they shouldn't 2017-09-03 11:21:42 +02:00
Lonami Exo
db6fd4bdc2 Fix RPC errors being ignored due to modifying the wrong attribute 2017-09-03 11:19:28 +02:00
Lonami Exo
83f3f66113 Fix MtProtoSender never clearing self._pending_receive requests 2017-09-03 10:50:55 +02:00
Lonami Exo
4de4026bb3 Move the "constant read" thread to the main TelegramClient 2017-09-03 09:56:10 +02:00
Lonami Exo
9bc1f64efe Move update handling to the MtProtoSender, being functional again 2017-09-02 21:46:44 +02:00
Lonami Exo
21eaf8bd72 Allow setting whether the MtProtoSender should use constant_read 2017-09-02 21:27:11 +02:00
Lonami Exo
863d2e8368 Make confirm_received a flag, avoid race conditions, fix bg RPCError
There was a race condition between TelegramBareClient.invoke
receiving part and MtProtoSender._handle_rpc_result actually
reading the result after setting request.confirmed = True.

The .confirmed is now a threading.Event to avoid the sleep(0.1).

RPC errors have been moved inside the request so they're not
raised on a background thread anymore.
2017-09-02 20:41:00 +02:00
Lonami Exo
b908296efa Remove unused TcpClien.read(timeout=...) param, change other accessors 2017-09-02 19:33:42 +02:00
Lonami Exo
43b79c3d36 Add a thread to constantly read messages from the network 2017-09-02 18:27:22 +02:00
Lonami Exo
fa22a3f848 Create a centralized Connection class, replaces TcpTransport (#112) 2017-08-28 21:23:31 +02:00
Lonami Exo
00b5b5021b Report errors to pwrtelegram.xyz by default 2017-08-25 15:34:20 +02:00
Lonami Exo
7844cd358e Attempt at making layer migrations more smooth (#158) 2017-07-26 16:10:45 +02:00
Lonami Exo
160a3699ac Fix confusing names "MtProtoRequest" and ".confirmed" (#176)
This also fixes the annoyingly confusing message:
"Odd msg_seqno expected (relevant message), but even received."
2017-07-24 16:54:48 +02:00
Lonami Exo
1f7ac71187 Debug level should always be used for logging since it's a library 2017-07-10 15:21:20 +02:00
Lonami Exo
83c8e98448 Ensure that message ids are signed once again 2017-06-27 18:45:52 +02:00
Lonami Exo
e4fbd87c75 Turn timeout into a property instead leaving it as a parameter 2017-06-22 11:43:42 +02:00
Lonami Exo
a9a5c7e254 Use signed longs for every request_id (#138 follow-up) 2017-06-21 10:21:09 +02:00
Lonami Exo
697434be37 Don't do anything on .connect() if it's already connected 2017-06-20 09:46:37 +02:00
Lonami Exo
8afb0a3f6b Rename Request.msg_id to request_msg_id to avoid name clash (fix #122) 2017-06-18 10:01:59 +02:00
Lonami Exo
2b85463ce6 Don't ignore more possible updates on .receive_updates() (closes #117) 2017-06-16 15:36:47 +02:00
Lonami Exo
3ed59d08e5 Fix commit 65912f9 by properly skipping lost messages 2017-06-11 17:53:53 +02:00
Lonami Exo
65912f926b Allow to send more than one request before receiving them (#105) 2017-06-11 14:58:16 +02:00