Apollo 10.0
自动驾驶开放平台
Client类 参考

#include <client.h>

类 Client 继承关系图:
Client 的协作图:

Public 成员函数

 Client (Node *node, Clients *clients, boost::asio::ip::tcp::socket socket)
 
 ~Client ()
 
void start ()
 
void stop ()
 
void publish (const std::string &channel, const std::string &msg)
 

详细描述

在文件 client.h18 行定义.

构造及析构函数说明

◆ Client()

Client::Client ( Node node,
Clients clients,
boost::asio::ip::tcp::socket  socket 
)

在文件 client.cc28 行定义.

29 : node(*node), clients(*clients), socket(std::move(s)) {
30 auto endpoint = socket.remote_endpoint();
31 AINFO << "Client [" << endpoint.address() << ":" << endpoint.port()
32 << "] connected";
33}
#define AINFO
Definition log.h:42

◆ ~Client()

Client::~Client ( )

在文件 client.cc35 行定义.

35{}

成员函数说明

◆ publish()

void Client::publish ( const std::string &  channel,
const std::string &  msg 
)

在文件 client.cc294 行定义.

294 {
295 std::lock_guard<std::mutex> lock(publish_mutex);
296 if (writing.empty()) {
297 fill_data(&writing, channel, msg);
298 boost::asio::async_write(
299 socket, boost::asio::buffer(writing.data(), writing.size()),
300 boost::bind(&Client::handle_write, shared_from_this(),
301 boost::asio::placeholders::error));
302 } else if (pending.size() < MAX_PENDING_SIZE) {
303 fill_data(&pending, channel, msg);
304 } else {
305 // If pending size is larger than MAX_PENDING_SIZE, discard the message.
306 AERROR << "Pending size too large. Discard message.";
307 }
308}
void fill_data(std::vector< uint8_t > *data, const std::string &channel, const std::string &msg)
Definition client.cc:271
#define AERROR
Definition log.h:44

◆ start()

void Client::start ( )

在文件 client.cc37 行定义.

37 {
38 socket.async_read_some(
39 boost::asio::buffer(temp, sizeof(temp)),
40 boost::bind(&Client::handle_read, shared_from_this(),
41 boost::asio::placeholders::error,
42 boost::asio::placeholders::bytes_transferred));
43}

◆ stop()

void Client::stop ( )

在文件 client.cc45 行定义.

45{ socket.close(); }

该类的文档由以下文件生成: