forked from zii/mtproto.research
-
Notifications
You must be signed in to change notification settings - Fork 0
/
收发消息.txt
299 lines (294 loc) · 9.45 KB
/
收发消息.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
## 收发消息
发送者A, 接收者B
消息ID的唯一性问题: 对话类型分user,group,channel. user和group的消息ID都是每个人一个. channel是所有人共用一套ID, 每个channel一个ID.
也就是说单人消息和群组消息, 是每个用户存一份自己的消息副本. 如果群组有200个人, 那就是一条同样的消息存200份, 而频道只存一份.
每个用户要保存自己的一套对话列表, 比如一个频道有10万人, 数据库就得有10万条对话.
群消息, 只要有一个人看过消息就可以给发送者发送已读回执.
A发出消息
09-03 09:07:36.940 D/tmessages: >>>>>>>> 发送请求:
TLRPC.TL_messages_sendMessage#fa88427a {
background: false,
clear_draft: true,
entities: [],
flags: 0,
message: "a",
no_webpage: false,
peer: TLRPC.TL_inputPeerUser#7b8e7de6 {
access_hash: 9180646263438742402 LONG,
channel_id: 0,
chat_id: 0,
user_id: 571691373,
},
random_id: -2470383236444931269 LONG,
reply_markup: null,
reply_to_msg_id: 0,
silent: false,
}
A的消息ID=480, pts+1=1355
09-03 09:07:37.637 D/tmessages: <<<<<<<< 收到响应(TL_messages_sendMessage):
TLRPC.TL_updateShortSentMessage#11f1331c {
chat_id: 0,
chats: [],
date: 1535936862,
entities: [],
flags: 642,
from_id: 0,
fwd_from: null,
id: 480,
media: TLRPC.TL_messageMediaEmpty#3ded6320 {
address: null,
audio_unused: null,
bytes: null,
caption: null,
currency: null,
description: null,
document: null,
first_name: null,
flags: 0,
game: null,
geo: null,
last_name: null,
period: 0,
phone_number: null,
photo: null,
provider: null,
receipt_msg_id: 0,
shipping_address_requested: false,
start_param: null,
test: false,
title: null,
total_amount: 0 LONG,
ttl_seconds: 0,
user_id: 0,
venue_id: null,
venue_type: null,
video_unused: null,
webpage: null,
},
media_unread: false,
mentioned: false,
message: null,
out: true,
pts: 1355,
pts_count: 1,
reply_to_msg_id: 0,
seq: 0,
seq_start: 0,
silent: false,
update: null,
updates: [],
user_id: 0,
users: [],
via_bot_id: 0,
}
B收到消息ID=228, pts+1=625
09-03 09:07:40.586 D/tmessages: <<<<<<<<<<<<<<<<<< 收到Updates:
TLRPC.TL_updateShortMessage#914fbf11 {
chat_id: 0,
chats: [],
date: 1535936862,
entities: [],
flags: 0,
from_id: 0,
fwd_from: null,
id: 228,
media: null,
media_unread: false,
mentioned: false,
message: "a",
out: false,
pts: 625,
pts_count: 1,
reply_to_msg_id: 0,
seq: 0,
seq_start: 0,
silent: false,
update: null,
updates: [],
user_id: 559876994,
users: [],
via_bot_id: 0,
}
B点开对话, 请求历史消息, offset_id=226上次消息ID.
09-03 09:12:59.423 D/tmessages: >>>>>>>>>>>>>>>>>> 发送请求:
TLRPC.TL_messages_getHistory#afa92846 {
add_offset: 0,
limit: 50,
max_id: 0,
min_id: 0,
offset_date: 0,
offset_id: 226,
peer: TLRPC.TL_inputPeerUser#7b8e7de6 {
access_hash: -6763463637624469595 LONG,
channel_id: 0,
chat_id: 0,
user_id: 559876994,
},
}
09-03 09:13:00.161 D/tmessages: <<<<<<<<<<<<<<<<<< 收到响应(org.telegram.tgnet.TLRPC$TL_messages_messagesSlice@a0a3573):
TLRPC.TL_messages_messagesSlice#b446ae3 {
chats: [],
count: 3,
flags: 0,
messages: [],
pts: 0,
users: [
TLRPC.TL_user#2e13f4c3 {
access_hash: -6763463637624469595 LONG,
bot: false,
bot_chat_history: false,
bot_info_version: 0,
bot_inline_geo: false,
bot_inline_placeholder: null,
bot_nochats: false,
contact: false,
deleted: false,
explicit_content: false,
first_name: "zii",
flags: 107,
id: 559876994,
inactive: false,
lang_code: null,
last_name: null,
min: false,
mutual_contact: false,
phone: null,
photo: TLRPC.TL_userProfilePhoto#d559d8c8 {
photo_big: TLRPC.TL_fileLocation#53d69076 {
dc_id: 5,
iv: null,
key: null,
local_id: 98777,
secret: 1294871521216147374 LONG,
volume_id: 852930096 LONG,
},
photo_id: 2404653379469027252 LONG,
photo_small: TLRPC.TL_fileLocation#53d69076 {
dc_id: 5,
iv: null,
key: null,
local_id: 98775,
secret: 1545841904406147006 LONG,
volume_id: 852930096 LONG,
},
},
restricted: false,
restriction_reason: null,
self: false,
status: TLRPC.TL_userStatusOffline#8c703f {
expires: 1535937161,
},
username: "gamcat",
verified: false,
}
],
}
B读历史消息
09-03 09:13:00.066 D/tmessages: >>>>>>>>>>>>>>>>>> 发送请求:
TLRPC.TL_messages_readHistory#e306d3a {
max_id: 228,
peer: TLRPC.TL_inputPeerUser#7b8e7de6 {
access_hash: -6763463637624469595 LONG,
channel_id: 0,
chat_id: 0,
user_id: 559876994,
},
}
服务器返回是否存影响pts队列: pts+1=626, pts_count=0表示上次已经标记过, 不再+1.
09-03 09:13:00.531 D/tmessages: <<<<<<<<<<<<<<<<<< 收到响应(org.telegram.tgnet.TLRPC$TL_messages_affectedMessages@b276953):
TLRPC.TL_messages_affectedMessages#84d19185 {
pts: 626,
pts_count: 1,
}
A收到对方已读回执, pts+1=1356, max_id=480刚才发的ID
updateReadHistoryOutbox: 对方读了我的发件箱历史消息
09-03 09:12:57.440 D/tmessages: <<<<<<<<<<<<<<<<<< 收到Updates:
TLRPC.TL_updates#74ae4240 {
chat_id: 0,
chats: [],
date: 1535937181,
entities: [],
flags: 0,
from_id: 0,
fwd_from: null,
id: 0,
media: null,
media_unread: false,
mentioned: false,
message: null,
out: false,
pts: 0,
pts_count: 0,
reply_to_msg_id: 0,
seq: 0,
seq_start: 0,
silent: false,
update: null,
updates: [
TLRPC.TL_updateReadHistoryOutbox#2f2f21bf {
peer: TLRPC.TL_peerUser#9db1bc6d {
channel_id: 0,
chat_id: 0,
user_id: 571691373,
},
action: null,
available_min_id: 0,
blocked: false,
channel_id: 0,
chat: null,
chat_id: 0,
chat_instance: 0 LONG,
data: null,
date: 0,
dc_options: [],
difference: null,
draft: null,
enabled: false,
entities: [],
first_name: null,
flags: 0,
foreign_link: null,
game_short_name: null,
geo: null,
inbox_date: 0,
inviter_id: 0,
is_admin: false,
key: null,
last_name: null,
masks: false,
max_date: 0,
max_id: 480,
media: null,
messages: [],
my_link: null,
notify_settings: null,
offset: null,
participant: null,
participants: null,
phone: null,
phone_call: null,
photo: null,
pinned: false,
popup: false,
previous: false,
pts: 1356,
pts_count: 1,
qts: 0,
query: null,
query_id: 0 LONG,
random_id: 0 LONG,
rules: [],
status: null,
stickerset: null,
type: null,
user_id: 0,
username: null,
version: 0,
views: 0,
webpage: null,
}
],
user_id: 0,
users: [],
via_bot_id: 0,
}