tdesktop/Telegram/SourceFiles/mtproto/details/mtproto_tcp_socket.h

38 lines
984 B
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
2019-12-02 13:10:19 +00:00
#include "mtproto/details/mtproto_abstract_socket.h"
2019-12-02 13:10:19 +00:00
namespace MTP::details {
class TcpSocket final : public AbstractSocket {
public:
2019-07-08 16:02:45 +00:00
TcpSocket(not_null<QThread*> thread, const QNetworkProxy &proxy);
void connectToHost(const QString &address, int port) override;
2019-07-28 16:00:42 +00:00
bool isGoodStartNonce(bytes::const_span nonce) override;
void timedOut() override;
bool isConnected() override;
2019-07-08 13:56:09 +00:00
bool hasBytesAvailable() override;
int64 read(bytes::span buffer) override;
void write(bytes::const_span prefix, bytes::const_span buffer) override;
int32 debugState() override;
static void LogError(int errorCode, const QString &errorText);
private:
2019-07-08 13:56:09 +00:00
void handleError(int errorCode);
QTcpSocket _socket;
};
2019-12-02 13:10:19 +00:00
} // namespace MTP::details