Add separate on_update callback.

This commit is contained in:
levlam 2021-09-10 16:31:04 +03:00
parent e6799e3054
commit 55e69f65af
5 changed files with 18 additions and 9 deletions

View File

@ -140,6 +140,9 @@ class PingConnectionPingPong final
return Status::OK();
}
Status on_update(BufferSlice packet) final {
return Status::OK();
}
void on_message_ack(uint64 id) final {
}
Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) final {

View File

@ -518,7 +518,7 @@ Status SessionConnection::on_slice_packet(const MsgInfo &info, Slice packet) {
<< " in container " << container_id_ << " from session " << auth_data_->get_session_id()
<< " with message_id " << info.message_id << ", main_message_id = " << main_message_id_
<< ", seq_no = " << info.seq_no << " and original size " << info.size;
return callback_->on_message_result_ok(0, as_buffer_slice(packet), info.size);
return callback_->on_update(as_buffer_slice(packet));
}
}

View File

@ -109,6 +109,8 @@ class SessionConnection final
virtual void on_container_sent(uint64 container_id, vector<uint64> msgs_id) = 0;
virtual Status on_pong() = 0;
virtual Status on_update(BufferSlice packet) = 0;
virtual void on_message_ack(uint64 id) = 0;
virtual Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) = 0;
virtual void on_message_result_error(uint64 id, int code, string message) = 0;

View File

@ -710,15 +710,17 @@ void Session::mark_as_unknown(uint64 id, Query *query) {
unknown_queries_.insert(id);
}
Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) {
if (id == 0) {
Status Session::on_update(BufferSlice packet) {
if (is_cdn_) {
return Status::Error("Got update from CDN connection");
return Status::Error("Receive at update from CDN connection");
}
last_success_timestamp_ = Time::now();
return_query(G()->net_query_creator().create_update(std::move(packet)));
return Status::OK();
}
Status Session::on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) {
last_success_timestamp_ = Time::now();
TlParser parser(packet.as_slice());

View File

@ -206,6 +206,8 @@ class Session final
void on_container_sent(uint64 container_id, vector<uint64> msg_ids) final;
Status on_update(BufferSlice packet) final;
void on_message_ack(uint64 id) final;
Status on_message_result_ok(uint64 id, BufferSlice packet, size_t original_size) final;
void on_message_result_error(uint64 id, int error_code, string message) final;