载入中...
搜索中...
未找到
Channel.h
浏览该文件的文档.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7namespace eve::data {
8class ByteData;
9}
10
11namespace eve::network {
12
13class TcpSocket;
14class Network;
15
21class Channel {
22public:
24 explicit Channel(TcpSocket* socket);
25 ~Channel();
26
34 bool sendMsgString(std::string s);
36 TcpSocket* getSocket() const { return socket_; }
37
42 void feed(const std::vector<char>& bytes);
43
44private:
45 TcpSocket* socket_ = nullptr;
46 std::vector<char> buffer_;
47 uint32_t pendingLen_ = 0;
48 bool hasLen_ = false;
49};
50
51} // namespace eve::network
Light2D::Data * data
uint32_t s
Definition Weather.cpp:28
In-memory byte buffer implementing eve::Data (ref-counted).
Definition ByteData.h:11
Length-prefixed (big-endian uint32) message framing over a TcpSocket. sendMsg() writes one framed mes...
Definition Channel.h:21
bool sendMsg(eve::data::ByteData *data)
Sends one framed message.
Definition Channel.cpp:38
TcpSocket * getSocket() const
The underlying TCP socket, or nullptr.
Definition Channel.h:36
void feed(const std::vector< char > &bytes)
Feeds received bytes into the frame parser. Called on the main thread from Network::pump / the emitCo...
Definition Channel.cpp:65
bool sendMsgString(std::string s)
Sends a string payload as one framed message (empty strings are rejected).
Definition Channel.cpp:59
TCP socket backed by Poco::Net; supports both client (connect) and server (listen/accept) roles....
Definition TcpSocket.h:28