本文整理汇总了C++中OutputBuffer::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputBuffer::reset方法的具体用法?C++ OutputBuffer::reset怎么用?C++ OutputBuffer::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputBuffer
的用法示例。
在下文中一共展示了OutputBuffer::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_accept
bool test_accept(LocalNode &node)
throw (EpiException)
{
node.publishPort();
std::auto_ptr<Connection> connection(node.accept());
std::auto_ptr<MailBox> mailbox(node.createMailBox(connection.get()));
connection->start();
std::auto_ptr<ErlangMessage> msg;
ErlTerm* received_term;
OutputBuffer *buffer = mailbox->newOutputBuffer();
bool loop = true;
while (loop) {
msg.reset(mailbox->receiveMsg());
if (!(msg->messageType() == ERL_MSG_SEND ||
msg->messageType() == ERL_MSG_REG_SEND)) {
std::cout << "Message is not SEND type\n";
return false;
}
received_term = msg->getMsg();
if (msg->messageType() == ERL_MSG_REG_SEND) {
std::cout << "Received to " << ((RegSendMessage *) msg.get())->getRecipientName() <<
": " << received_term->toString() << "\n";
} else {
std::cout << "Received to " << ((SendMessage *) msg.get())->getRecipientPid()->toString() <<
": " << received_term->toString() << "\n";
}
if (received_term->instanceOf(ERL_TUPLE)) {
ErlTuple *tuple = (ErlTuple *) received_term;
if (tuple->arity() == 2) {
ErlTerm* term1 = tuple->elementAt(0);
ErlTerm* term2 = tuple->elementAt(1);
if (term1->instanceOf(ERL_PID)) {
std::cout << "Sending " << term2->toString() <<
" to " << term1->toString() << "\n";
buffer->reset();
buffer->writeTerm(term2);
mailbox->sendBuf((ErlPid *) term1, buffer);
std::cout << "Sent.\n";
}
}
}
if (received_term->instanceOf(ERL_ATOM)) {
if (((ErlAtom *) received_term)->atomValue() == "exit") {
loop = false;
}
}
}
return true;
}