本文整理汇总了C++中MessagePtr类的典型用法代码示例。如果您正苦于以下问题:C++ MessagePtr类的具体用法?C++ MessagePtr怎么用?C++ MessagePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MessagePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NetworkInterfaceStopTransmittingEvent
void P2PNetworkInterface::send() {
MessagePtr msg;
stringstream info;
uint64_t transmissionDuration;
double rate;
if (!connectedInterface) {
info << "*** WARNING *** [block " << hostBlock->blockId << ",interface " << globalId <<"] : trying to send a Message but no interface connected";
BaseSimulator::getScheduler()->trace(info.str());
return;
}
if (outgoingQueue.size()==0) {
info << "*** ERROR *** [block " << hostBlock->blockId << ",interface " << globalId <<"] : The outgoing buffer of this interface should not be empty !";
BaseSimulator::getScheduler()->trace(info.str());
exit(EXIT_FAILURE);
}
msg = outgoingQueue.front();
outgoingQueue.pop_front();
rate = dataRate - dataRateVariability + (generator()/(double)RAND_MAX) * 2 * dataRateVariability;
transmissionDuration = (msg->size()*8000000ULL)/rate;
messageBeingTransmitted = msg;
messageBeingTransmitted->sourceInterface = this;
messageBeingTransmitted->destinationInterface = connectedInterface;
availabilityDate = BaseSimulator::getScheduler()->now()+transmissionDuration;
//info << "*** sending (interface " << localId << " of block " << hostBlock->blockId << ")";
//getScheduler()->trace(info.str());
BaseSimulator::getScheduler()->schedule(new NetworkInterfaceStopTransmittingEvent(BaseSimulator::getScheduler()->now()+transmissionDuration, this));
}
示例2: while
void Client::receiveMessages()
{
while(d->msgqueue->isPending()) {
MessagePtr msg = d->msgqueue->getPending();
if(d->session.isNull()) {
// No session? We must be in the login phase
if(msg->type() == protocol::MSG_COMMAND)
emit loginMessage(msg);
else
log(Log().about(Log::Level::Warn, Log::Topic::RuleBreak).message(
QString("Got non-login message (type=%1) in login state").arg(msg->type())
));
} else {
// Enforce origin ID, except when receiving a snapshot
if(d->session->initUserId() != d->id)
msg->setContextId(d->id);
if(isHoldLocked())
d->holdqueue << msg;
else
d->session->handleClientMessage(*this, msg);
}
}
}
示例3: onProtobufMessage
void AprilServer::onProtobufMessage(const muduo::net::TcpConnectionPtr& conn,
const MessagePtr& message,
muduo::Timestamp time)
{
const google::protobuf::Descriptor* descriptor = message->GetDescriptor();
const google::protobuf::FieldDescriptor* id_field = descriptor->FindFieldByName("id");
const google::protobuf::FieldDescriptor* sync_field = descriptor->FindFieldByName("sync");
const google::protobuf::Reflection* reflection = message->GetReflection();
int32_t id = reflection->GetInt32(*message, id_field);
bool sync = reflection->GetBool(*message, sync_field);
LOG_INFO << "receive - id " << id << " sync " << sync;
if (_sync && sync) {
_dict->swap_dict();
_sync = false;
}
april::response mess;
int value = 0;
_dict->seek(id, &value);
mess.set_id(value);
mess.set_sync(_sync);
_codec.send(conn, mess);
}
示例4:
Arcus::PythonMessage::PythonMessage(const MessagePtr& message)
{
_shared_message = message;
_message = message.get();
_reflection = message->GetReflection();
_descriptor = message->GetDescriptor();
}
示例5: sendMsgQueue
void ProxyServer::sendMsgQueue(const MessagePtr& message,std::string title)
{
std::string msgname = message->GetTypeName();
std::string titlename = "push:" + msgname;
std::string value = message->DebugString();
LOG4CXX_INFO(log4cxx::Logger::getLogger(PROXYSERVER),value);
}
示例6: handleReceivedMessage
LocalFork::MessageAction LocalFork::handleReceivedMessage(MessagePtr msg, const AffectedArea &area)
{
// No local fork: nothing to do. It is possible that we get a message from ourselves
// that is not in the local fork, but this is not an error. It could happen when
// playing back recordings, for example.
if(_messages.isEmpty())
return CONCURRENT;
// Check if this is our own message that has finished its roundtrip
if(msg->contextId() == _messages.first()->contextId()) {
if(msg.equals(_messages.first())) {
_messages.removeFirst();
_areas.removeFirst();
return ALREADYDONE;
} else {
// Unusual, but not an error. This can happen when the layer is locked while drawing
// or when an operator performs some function on behalf the user.
qWarning("local fork out of sync: discarding...");
clear();
return ROLLBACK;
}
}
// OK, so this is another user's message. Check if it is concurrent
for(const AffectedArea &a : _areas) {
if(!area.isConcurrentWith(a)) {
return ROLLBACK;
}
}
return CONCURRENT;
}
示例7: while
void Client::flush()
{
while (mRunning)
{
// waits for messages to send
boost::unique_lock<boost::mutex> lock(mWMutex);
while (mWriteQ.empty() && mRunning)
mWCond.wait(lock);
if (mRunning)
{
// get and remove next item
MessagePtr msg = mWriteQ.front();
mWriteQ.pop_front();
// send it to the thread, but wait for other writes to finish
mWSMutex.lock();
boost::asio::async_write(mSocket,
boost::asio::buffer(msg->raw(),
msg->rawLength()),
boost::bind(&Client::onWritten,
this,
boost::asio::placeholders::error));
}
}
printf("Done flushing...\n");
}
示例8: api
void
api ()
{
if ((current_.status == Protocol::TS_COMMITED ||
current_.status == Protocol::TS_ABORTED) &&
separation_duration_ == 0) // no transaction in progress
{
// start new transaction
// Note that in_ is already locked by Scheduler
MessagePtr m (in_.front ());
in_.pop ();
if (typeid (*m) == typeid (Send))
{
send_ = SendPtr (dynamic_cast<Send*> (m.release ()));
}
else
{
// cerr << "Expecting Send but received " << typeid (*m).name ()
// << endl;
::abort ();
}
current_.id++;
current_.status = Protocol::TS_BEGIN;
initiated_ = true;
// if (trace_) cerr << "starting transaction with id " << current_.id
// << endl;
}
}
示例9: OnMessage
void Server::OnMessage(ConnectionHandle connection, MessagePtr data)
{
Urho3D::MutexLock lock(mutexEvents_);
ConnectionPtr connectionPtr = server_->get_con_from_hdl(connection);
if (data->get_opcode() == websocketpp::frame::opcode::TEXT)
{
String textMsg(data->get_payload().c_str());
LogInfo("[WebSocketServer]: on_utf8_message: size=" + String(textMsg.Length()) + " msg=" + textMsg);
}
else if (data->get_opcode() == websocketpp::frame::opcode::BINARY)
{
const std::string &payload = data->get_payload();
if (payload.size() == 0)
{
LogError("[WebSocketServer]: Received 0 sized payload, ignoring");
return;
}
SocketEvent *event = new SocketEvent(connectionPtr, SocketEvent::Data);
event->data = DataSerializerPtr(new kNet::DataSerializer(payload.size()));
event->data->AddAlignedByteArray(&payload[0], payload.size());
events_.Push(event);
}
}
示例10: print_introspection
void print_introspection(MessagePtr message, const std::string& prefix) {
if (!message->hasInstance()) {
std::cout << "No instance!" << std::endl;
}
for(Message::const_iterator it = message->begin(); it != message->end(); ++it) {
FieldPtr field = *it;
std::cout << prefix << std::string(field->getDataType()) << " " << std::string(field->getName()) << " = ";
if (field->isContainer()) std::cout << "[";
if (field->isMessage()) {
std::cout << std::endl;
for(std::size_t i = 0; i < field->size(); i++) {
MessagePtr expanded = field->expand(i);
if (!expanded) {
std::cout << prefix << " (unknown)" << std::endl;
continue;
}
print_introspection(expanded, prefix + " ");
}
std::cout << prefix;
} else {
for(std::size_t i = 0; i < field->size(); i++) {
if (i > 0) std::cout << ", ";
std::cout << field->as<std::string>(i);
}
}
if (field->isContainer()) std::cout << "]";
std::cout << std::endl;
}
}
示例11:
void
NetServer::onStateMessage( MessagePtr m )
{
K_ASSERT( m.Get() != 0 );
NetStateMessage* nsm = static_cast<NetStateMessage*>( m.Get() );
switch ( nsm->state )
{
case NetStateMessage::TCP_CLOSED:
{
NetGroupMap::iterator i = m_groups.find( nsm->groupId );
if ( i != m_groups.end() )
{
NetGroup* group = i->second;
if ( group != 0 )
{
group->Leave( nsm->connectionId );
}
}
}
break;
}
m_listener->Notify( m );
}
示例12: HandleResponses
void Peer::HandleResponses(WMessagePtr pWMsg)
{
MessagePtr pMsg = pWMsg->GetMsg();
// get the peer list if given in message
std::vector<RemotePeers> peerList = pMsg->m_peerList;
if( peerList.size() > 0 ) {
long ts = pMsg->m_timestamp;
this->HandlePeerList(peerList, ts);
}
// see if it is a task message
if( pMsg->IsTaskMessage() ) {
int msgTaskId = pMsg->m_taskId;
// get the task and forward the message
std::map<int, TaskPtr>::iterator it;
it = m_taskList.find(msgTaskId);
if( it != m_taskList.end() ) {
TaskPtr pTask = (*it).second;
pTask->GetMessageQueue()->PutMessage(pWMsg);
}
else {
Log(CONSOLE, L"No Task Related to Task Response Message Received for taskId: %d\n", msgTaskId);
}
return;
}
switch(pMsg->m_respType) {
case GET_ONLINE_RESP:
HandleOnlineResp(pMsg);
break;
default:
break;
}
}
示例13: send_all
void send_all(const T& value) {
MessagePtr msg = std::make_shared<Message>(sizeof(T));
msg->set_body_length(sizeof(T));
std::memcpy(msg->body(), &value, sizeof(T));
msg->encode_header();
send_all(msg);
}
示例14: writeMessage
void ArcnetIO::writeMessage( const MessagePtr& msg )
{
if ( !isEnabled_ )
{
THROW_ERROR("Arcnet subsystem has not been enabled.");
}
this->send( msg->msg(), msg->length() );
}
示例15: Alloc
MessagePtr Message::Alloc(const char* data, uint32_t len)
{
MessagePtr msg;
if (len > 0)
{
msg.reset(new Message(data, len));
}
return msg;
}