static void send_replies(char *buff, int *index) { ei_x_buff xbuf; gint arity, i; make_xbuf(&xbuf); if ( ! ((arity = gn_get_list(&xbuf, buff, index)) > -1) ) { send_xbuf(&xbuf); return; } for (i = 0; i < arity; i++) { if ( ((i+1)%1000) == 0 ) { ei_x_encode_empty_list(&xbuf); send_xbuf(&xbuf); make_xbuf(&xbuf); } ei_x_encode_list_header(&xbuf, 1); if ( ! make_reply(&xbuf, buff, index) ) break; } ei_x_encode_empty_list(&xbuf); send_xbuf(&xbuf); }
static void make_reply_list(ei_x_buff *xbuf, char *buff, int *index) { gint arity, i; if ( ! ((arity = gn_get_list(xbuf, buff, index)) > -1) ) return; gn_wrap_ans("reply",xbuf); for (i = 0; i < arity; i++) { ei_x_encode_list_header(xbuf, 1); if ( ! make_reply(xbuf, buff, index) ) break; } ei_x_encode_empty_list(xbuf); }
void handler::handle_read(const boost::system::error_code &err, size_t size) { if (err) { close(); return; } auto req = parse_request(size); std::string content = ""; if (req > 0) { dnet_log(m_monitor.node(), DNET_LOG_DEBUG, "monitor: server: got statistics request for categories: %lx from: %s:%d", req, m_remote.c_str(), m_socket.remote_endpoint().port()); content = m_monitor.get_statistics().report(req); } std::string reply = make_reply(req, content); async_write(reply); }
void chat_app::start() { INVARIANT(root()); INVARIANT(layout()); INVARIANT(_conversation); //message list _messages = new QTextEdit; _messages->setReadOnly(true); _messages->setWordWrapMode(QTextOption::WordWrap); _messages->setUndoRedoEnabled(false); _main_layout->addWidget(_messages, 0, 0, 1, 2); //text edit _message = new QLineEdit; _main_layout->addWidget(_message, 1, 0); //send button _send = new QPushButton; make_reply(*_send); _send->setToolTip(tr("Send")); _main_layout->addWidget(_send, 1, 1); connect(_message, SIGNAL(returnPressed()), this, SLOT(send_message())); connect(_send, SIGNAL(clicked()), this, SLOT(send_message())); //setup mail service _mail_service = new mail_service{_mail, this}; _mail_service->start(); //join the chat join(); adjust_size(); //Let user know this widget is a chat. add_text(make_message_str("red", "notice", "Chat Started")); INVARIANT(_conversation); INVARIANT(_mail); INVARIANT(_sender); }