2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2019-01-31 03:13:59 +01:00
|
|
|
#include "td/mtproto/TransportType.h"
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/buffer.h"
|
2019-02-12 21:48:16 +01:00
|
|
|
#include "td/utils/common.h"
|
2018-09-07 02:41:21 +02:00
|
|
|
#include "td/utils/port/detail/PollableFd.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
namespace mtproto {
|
2019-01-31 03:05:40 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
class IStreamTransport {
|
|
|
|
public:
|
|
|
|
IStreamTransport() = default;
|
|
|
|
IStreamTransport(const IStreamTransport &) = delete;
|
|
|
|
IStreamTransport &operator=(const IStreamTransport &) = delete;
|
|
|
|
virtual ~IStreamTransport() = default;
|
|
|
|
virtual Result<size_t> read_next(BufferSlice *message, uint32 *quick_ack) = 0;
|
|
|
|
virtual bool support_quick_ack() const = 0;
|
|
|
|
virtual void write(BufferWriter &&message, bool quick_ack) = 0;
|
|
|
|
virtual bool can_read() const = 0;
|
|
|
|
virtual bool can_write() const = 0;
|
|
|
|
virtual void init(ChainBufferReader *input, ChainBufferWriter *output) = 0;
|
|
|
|
virtual size_t max_prepend_size() const = 0;
|
2018-06-15 20:54:22 +02:00
|
|
|
virtual size_t max_append_size() const = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
virtual TransportType get_type() const = 0;
|
2019-07-04 12:56:10 +02:00
|
|
|
virtual bool use_random_padding() const = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
unique_ptr<IStreamTransport> create_transport(TransportType type);
|
2019-01-31 03:05:40 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace mtproto
|
|
|
|
} // namespace td
|