本文整理汇总了C++中message_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ message_ptr类的具体用法?C++ message_ptr怎么用?C++ message_ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了message_ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: task
rpc_request_task::rpc_request_task(message_ptr& request, service_node* node)
: task(task_code(request->header().local_rpc_code), request->header().client.hash, node),
_request(request)
{
dbg_dassert (TASK_TYPE_RPC_REQUEST == spec().type, "task type must be RPC_REQUEST, please use DEFINE_TASK_CODE_RPC to define the task code");
}
示例2: marshall
int replication_app_base::dispatch_rpc_call(int code, message_ptr& request, bool ack_client)
{
auto it = _handlers.find(code);
if (it != _handlers.end())
{
if (ack_client)
{
message_ptr response = request->create_response();
int err = 0;
marshall(response->writer(), err);
it->second(request, response);
}
else
{
message_ptr response(nullptr);
it->second(request, response);
}
}
else if (ack_client)
{
message_ptr response = request->create_response();
error_code err = ERR_HANDLER_NOT_FOUND;
marshall(response->writer(), (int)err);
rpc::reply(response);
}
return 0;
}
示例3: on_message
void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
client::connection_ptr con = sip_client.get_con_from_hdl(hdl);
std::cout << "Received a reply:" << std::endl;
fwrite(msg->get_payload().c_str(), msg->get_payload().size(), 1, stdout);
received=true;
}
示例4: on_message
// Define a callback to handle incoming messages
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (const websocketpp::lib::error_code& e) {
}
}
示例5: on_message
void on_message(connection_ptr con, message_ptr msg) {
if (con->get_resource() == "/getcasecount") {
std::cout << "detected " << msg->get_payload() << " test cases." << std::endl;
m_case_count = atoi(msg->get_payload().c_str());
} else {
con->send(msg->get_payload(),msg->get_opcode());
}
}
示例6: on_recv_request
void rpc_server_session::on_recv_request(message_ptr& msg, int delay_ms)
{
msg->header().from_address = remote_address();
msg->header().from_address.port = msg->header().client.port;
msg->header().to_address = _net.address();
msg->server_session().reset(this);
return _net.on_recv_request(msg, delay_ms);
}
示例7: on_message
void websocketIO::on_message(websocketpp::connection_hdl hdl, message_ptr msg) {
boost::property_tree::ptree json;
std::istringstream iss(msg->get_payload());
boost::property_tree::read_json(iss, json);
std::string func = json.get<std::string> ("func");
if(messages.find(func) != messages.end()){
messages[func](this, msg->get_payload());
}
}
示例8: on_message
// Define a callback to handle incoming messages
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
std::cout << " and message: " << msg->get_payload() <<std::endl ;
std::cout << " opcode " << msg->get_opcode() <<std::endl ;
// s->send(hdl, msg->get_payload(), msg->get_opcode());
const char* msge = "{\"GESTURE\":\"Move Left\"}";
s->send(hdl, msge, websocketpp::frame::opcode::text);
}
示例9: on_message
void Handler::on_message(connection_ptr con, message_ptr msg)
{
if (msg->get_opcode() != websocketpp::frame::opcode::TEXT)
return;
Log::debug("client <%s>: <message> %s", plain(con).c_str(),
msg->get_payload().c_str());
publish(format_message(msg->get_payload()));
}
示例10: recv_msg
void sim_server_session::send(message_ptr& reply_msg)
{
message_ptr recv_msg(new message(reply_msg->writer().get_buffer()));
recv_msg->header().from_address = reply_msg->header().from_address;
recv_msg->header().to_address = reply_msg->header().to_address;
_client->on_recv_reply(recv_msg->header().id, recv_msg,
recv_msg->header().from_address == recv_msg->header().to_address ?
0 : (static_cast<sim_network_provider*>(&_net))->net_delay_milliseconds()
);
}
示例11: on_message
void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
client::connection_ptr con = c->get_con_from_hdl(hdl);
if (con->get_resource() == "/getCaseCount") {
std::cout << "Detected " << msg->get_payload() << " test cases."
<< std::endl;
case_count = atoi(msg->get_payload().c_str());
} else {
c->send(hdl, msg->get_payload(), msg->get_opcode());
}
}
示例12: on_message
void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
std::cout << "on_message called with hdl: " << hdl.lock().get()
<< " and message: " << msg->get_payload()
<< std::endl;
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (const websocketpp::lib::error_code& e) {
std::cout << "Echo failed because: " << e
<< "(" << e.message() << ")" << std::endl;
}
}
示例13: handleRx
void ReadUncompressed::handleRx(const message_ptr message)
{
if (!m_initialized)
{
m_initialized = check();
if (!m_initialized) m_error = true;
}
else
{
if (message->get_opcode() == websocketpp::frame::opcode::binary)
{
const std::string& bytes(message->get_payload());
const std::size_t rawNumBytes(bytes.size());
const std::size_t stride(m_layout->pointSize());
m_data.insert(m_data.end(), bytes.begin(), bytes.end());
const std::size_t wholePoints(m_data.size() / stride);
PointId nextId(m_view->size());
const PointId doneId(nextId + wholePoints);
const char* pos(m_data.data());
while (nextId < doneId)
{
for (const auto& dim : m_layout->dims())
{
m_view->setField(
dim,
m_layout->dimType(dim),
nextId,
pos);
pos += m_layout->dimSize(dim);
}
++nextId;
}
m_numBytesReceived += rawNumBytes;
m_data.assign(
m_data.begin() + wholePoints * stride,
m_data.end());
}
else
{
m_error = true;
}
}
}
示例14: on_message
void websocket_server::on_message(ws_socket* socket_, websocketpp::connection_hdl hdl, message_ptr msg) {
if(msg->get_payload() == "CC"){
cc_hdl_ = hdl;
clientConnected = true;
BOOST_LOG_TRIVIAL(info) << "Control Center connected via websocket";
}
else if (msg->get_payload() == "AL"){
al_hdl_ = hdl;
proxyConnected = true;
BOOST_LOG_TRIVIAL(info) << "Al-Proxy connected via websocket";
}
}
开发者ID:flair2005,项目名称:gesture-recognition-for-human-robot-interaction,代码行数:14,代码来源:websocket_server.cpp
示例15: response_client_message
void replica::response_client_message(message_ptr& request, error_code error, decree d/* = invalid_decree*/)
{
if (nullptr == request)
return;
message_ptr resp = request->create_response();
resp->writer().write(error);
dassert(error != ERR_OK, "");
dinfo("handle replication request with rpc_id = %016llx failed, err = %s",
request->header().rpc_id, error.to_string());
rpc::reply(resp);
}