Length-prefixed (big-endian uint32) message framing over a TcpSocket. sendMsg() writes one framed message; feed() consumes bytes and emits received frames as "chmsg" events on the main thread via the Event module. 更多...
#include <Channel.h>
Public 成员函数 | |
| Channel (TcpSocket *socket) | |
| Creates a channel over an existing socket (socket must be non-null). | |
| ~Channel () | |
| bool | sendMsg (eve::data::ByteData *data) |
| Sends one framed message. | |
| bool | sendMsgString (std::string s) |
| Sends a string payload as one framed message (empty strings are rejected). | |
| TcpSocket * | getSocket () const |
| The underlying TCP socket, or nullptr. | |
| void | feed (const std::vector< char > &bytes) |
| Feeds received bytes into the frame parser. Called on the main thread from Network::pump / the emitCompletion path. | |
详细描述
Length-prefixed (big-endian uint32) message framing over a TcpSocket. sendMsg() writes one framed message; feed() consumes bytes and emits received frames as "chmsg" events on the main thread via the Event module.
构造及析构函数说明
◆ Channel()
|
explicit |
Creates a channel over an existing socket (socket must be non-null).
在文件 Channel.cpp 第 30 行定义.
引用了 EV_PARAM_CHECK.
◆ ~Channel()
| eve::network::Channel::~Channel | ( | ) |
在文件 Channel.cpp 第 34 行定义.
引用了 eve::network::TcpSocket::network() , 以及 eve::network::Network::unbindChannel().
成员函数说明
◆ feed()
| void eve::network::Channel::feed | ( | const std::vector< char > & | bytes | ) |
Feeds received bytes into the frame parser. Called on the main thread from Network::pump / the emitCompletion path.
在文件 Channel.cpp 第 65 行定义.
引用了 c, eve::network::Channel, eve::network::ChClose, eve::network::ChMsg, eve::network::TcpSocket::close(), eve::network::Err, eve::network::NetCompletion::handle, eve::network::NetCompletion::kind, eve::network::kMaxFrameSize, eve::network::TcpSocket::network(), eve::network::NetCompletion::reason , 以及 eve::network::NetCompletion::type.
◆ getSocket()
|
inline |
◆ sendMsg()
| bool eve::network::Channel::sendMsg | ( | eve::data::ByteData * | data | ) |
Sends one framed message.
- 参数
-
data Payload bytes (must be non-null; size capped at kMaxFrameSize).
- 返回
- True when the frame was handed to the socket.
在文件 Channel.cpp 第 38 行定义.
引用了 c, eve::network::Channel, data, eve::network::Err, eve::network::kMaxFrameSize, n, eve::network::TcpSocket::network(), eve::network::Network::post(), eve::network::TcpSocket::send() , 以及 eve::network::NetCompletion::type.
被这些函数引用 sendMsgString().
◆ sendMsgString()
| bool eve::network::Channel::sendMsgString | ( | std::string | s | ) |
Sends a string payload as one framed message (empty strings are rejected).
在文件 Channel.cpp 第 59 行定义.
该类的文档由以下文件生成:
- src/modules/network/Channel.h
- src/modules/network/Channel.cpp