| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #ifndef TG_CALLS_RAW_TCP_SOCKET_H_ |
| 12 | #define TG_CALLS_RAW_TCP_SOCKET_H_ |
| 13 |
| 14 | #include <stddef.h> |
| 15 |
| 16 | #include <cstdint> |
| 17 | #include <memory> |
| 18 |
| 19 | #include "api/array_view.h" |
| 20 | #include "rtc_base/async_packet_socket.h" |
| 21 | #include "rtc_base/buffer.h" |
| 22 | #include "rtc_base/socket.h" |
| 23 | #include "rtc_base/socket_address.h" |
| 24 | #include "rtc_base/async_tcp_socket.h" |
| 25 |
| 26 | namespace rtc { |
| 27 |
| 28 | class RawTcpSocket : public AsyncTCPSocketBase { |
| 29 | public: |
| 30 | // Binds and connects `socket` and creates RawTcpSocket for |
| 31 | // it. Takes ownership of `socket`. Returns null if bind() or |
| 32 | // connect() fail (`socket` is destroyed in that case). |
| 33 | static RawTcpSocket* Create(Socket* socket, |
| 34 | const SocketAddress& bind_address, |
| 35 | const SocketAddress& remote_address); |
| 36 | explicit RawTcpSocket(Socket* socket); |
| 37 | ~RawTcpSocket() override {} |
| 38 |
| 39 | RawTcpSocket(const RawTcpSocket&) = delete; |
| 40 | RawTcpSocket& operator=(const RawTcpSocket&) = delete; |
| 41 |
| 42 | int Send(const void* pv, |
| 43 | size_t cb, |
| 44 | const rtc::PacketOptions& options) override; |
| 45 | size_t ProcessInput(rtc::ArrayView<const uint8_t>) override; |
| 46 |
| 47 | private: |
| 48 | bool did_send_mtproto_prologue_ = false; |
| 49 | }; |
| 50 |
| 51 | } // namespace rtc |
| 52 |
| 53 | #endif // TG_CALLS_RAW_TCP_SOCKET_H_ |
| 54 |