载入中...
搜索中...
未找到
Channel.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <cstdint>
6#include <string>
7#include <vector>
8
9namespace eve::data {
10class ByteData;
11}
12
13namespace eve::network {
14
15class TcpSocket;
16class Network;
17
24public:
26 explicit Channel(TcpSocket* socket);
28 ~Channel();
29
35 bool sendMsg(eve::data::ByteData* data);
37 bool sendMsgString(std::string s);
39 TcpSocket* getSocket() const { return socket_; }
40
45 void feed(const std::vector<char>& bytes);
46
47private:
48 TcpSocket* socket_ = nullptr;
49 std::vector<char> buffer_;
50 uint32_t pendingLen_ = 0;
51 bool hasLen_ = false;
52};
53
54} // namespace eve::network
const std::string & s
#define EVENGINE_API_PLATFORM
Definition Export.h:107
std::uint64_t bytes
In-memory byte buffer implementing eve::Data (ref-counted).
Definition ByteData.h:13
Length-prefixed (big-endian uint32) message framing over a TcpSocket. sendMsg() writes one framed mes...
Definition Channel.h:23
TcpSocket * getSocket() const
The underlying TCP socket, or nullptr.
Definition Channel.h:39
TCP socket backed by Poco::Net; supports both client (connect) and server (listen/accept) roles....
Definition TcpSocket.h:30