本文整理汇总了C++中MessagePtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ MessagePtr::get方法的具体用法?C++ MessagePtr::get怎么用?C++ MessagePtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessagePtr
的用法示例。
在下文中一共展示了MessagePtr::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Arcus::PythonMessage::PythonMessage(const MessagePtr& message)
{
_shared_message = message;
_message = message.get();
_reflection = message->GetReflection();
_descriptor = message->GetDescriptor();
}
示例2: onPubSubMessage
void onPubSubMessage(
const TcpConnectionPtr& connectionPtr,
const MessagePtr& messagePtr,
Timestamp) {
const PubSubMessage& message
= *dynamic_cast<PubSubMessage*>(messagePtr.get());
counters_.incrementInBoundMessage();
switch(message.op()) {
case Op::PUB:
distributePublish(
string(message.topic().data()), string(message.content().data())
);
break;
case Op::SUB:
doSubscribe(connectionPtr, string(message.topic().data()));
break;
case Op::UNSUB:
doUnsubscribe(connectionPtr, string(message.topic().data()));
break;
default:
LOG(ERROR) << "Unsupported message op: " << message.op();
connectionPtr->shutdown();
break;
}
}
示例3: recv
//FUZZ: disable check_for_lack_ACE_OS
size_t recv (void* msg, size_t size)
{
//FUZZ: enable check_for_lack_ACE_OS
AutoLock lock (mutex_);
while (true)
{
throw_if_failed ();
if (!in_recv_data_.empty ())
{
MessagePtr m (in_recv_data_.front ());
in_recv_data_.pop ();
std::type_info const* exp = &typeid (*m);
if (exp == typeid (Recv))
{
Recv* data = dynamic_cast<Recv*> (m.get ());
if (size < data->size ())
throw Group::InsufficienSpace ();
ACE_OS::memcpy (msg, data->payload (), data->size ());
return data->size ();
}
else
{
// cerr << "recv: group-scheduler messaging protocol violation. "
// << "unexpected message " << typeid (*m).name () << endl;
ACE_OS::abort ();
}
}
recv_cond_.wait ();
}
}
示例4: lock
void
execute ()
{
try
{
sock_.join (addr_);
auto_ptr<LinkListener> ll (new LinkListener (sock_, in_link_data_));
{
AutoLock lock (mutex_);
// Loop
//
//
while (true)
{
cond_.wait (&sync_schedule);
// "Loop of Fairness"
bool done = false;
do
{
// control message
//
//
if (!in_control_.empty ())
{
done = true;
break;
}
// outsync
//
//
if (sync_schedule < ACE_OS::gettimeofday ())
{
// OUTSYNC
outsync ();
// schedule next outsync
sync_schedule =
ACE_OS::gettimeofday () +
ACE_Time_Value (0, Protocol::SYNC_PERIOD);
}
// link message
//
//
if (!in_link_data_.empty ())
{
MessagePtr m (in_link_data_.front ());
in_link_data_.pop ();
std::type_info const* exp = &typeid (*m);
if (exp == typeid (LinkFailure))
{
// cerr << "link failure" << endl;
throw false;
}
else if (exp == typeid (LinkData))
{
LinkData* data = dynamic_cast<LinkData*> (m.get ());
// INSYNC, TL, CT
// Filter out loopback.
//
if (ACE_OS::strcmp (data->header().member_id.id, id_) != 0)
{
insync ();
transaction_list ();
current_transaction (data->header().current,
data->payload (),
data->size ());
}
}
else
{
// cerr << "unknown message type from link listener: "
// << typeid (*m).name () << endl;
ACE_OS::abort ();
}
}
// api message
//
//
if (!in_data_.empty ())
{
// API
api ();
}
//.........这里部分代码省略.........
示例5: processMessage
void ClientGame::processMessage(MessagePtr msg)
{
switch(msg->getType())
{
case MessageType::SRV_ASTEROID_SPAWN:
{
print("ClientGame: spawning asteroid\n");
AsteroidSpawnMessage *spawn_msg = static_cast<AsteroidSpawnMessage*>(msg.get());
AsteroidPtr ast(new Asteroid(this, spawn_msg->getData(), asteroid_data));
entities.push_back(ast);
asteroids.push_back(ast);
}
break;
case MessageType::SRV_SHIP_SPAWN:
{
ShipSpawnMessage *spawn_msg = static_cast<ShipSpawnMessage*>(msg.get());
const ShipSpawnData &d = spawn_msg->getData();
ShipPtr ship(new Ship(this, d));
entities.push_back(ship);
ships.push_back(ship);
print(format("ClientGame: spawning ship id=%1% name=%2%\n") % ship->getID() % ship->getName());
}
break;
case MessageType::SRV_BULLET_SPAWN:
{
BulletSpawnMessage *spawn_msg = static_cast<BulletSpawnMessage*>(msg.get());
const BulletSpawnData &d = spawn_msg->getData();
BulletPtr bullet(new Bullet(this, d));
entities.push_back(bullet);
if(Audio::distToListener(d.state.position) < 200.0f)
Audio::playSFX("sounds/laser0.wav", false, d.state.position, 0.5f, 10.0f);
print(format("ClientGame: spawning bullet id=%1%\n") % bullet->getID());
}
break;
case MessageType::SRV_SHIP_STATE:
{
ShipStateMessage *state_msg = static_cast<ShipStateMessage*>(msg.get());
int id = state_msg->getEntityID();
//print(format("ClientGame: received ship state data for ship id=%1%\n") % id);
//TODO use a map?
for(unsigned int i = 0; i < ships.size(); i++)
if(ships[i]->getID() == id)
{
ships[i]->setStateData(state_msg->getData());
break;
}
}
break;
case MessageType::SRV_SHIP_OWNER:
{
ShipOwnerMessage *owner_msg = static_cast<ShipOwnerMessage*>(msg.get());
print("owner message\n");
for(unsigned int i = 0; i < ships.size(); i++)
if(ships[i]->getID() == owner_msg->getData().ship_id)
{
print("owner message\n");
player_ship = ships[i];
ship_cam->setShip(player_ship);
break;
}
}
case MessageType::SRV_ASTEROID_STATE:
{
AsteroidStateMessage *state_msg = static_cast<AsteroidStateMessage*>(msg.get());
int id = state_msg->getEntityID();
//print(format("ClientGame: received asteroid state data for asteroid id=%1%\n") % id);
for(unsigned int i = 0; i < asteroids.size(); i++)
if(asteroids[i]->getID() == id)
{
asteroids[i]->setStateData(state_msg->getData());
break;
}
}
break;
case MessageType::SRV_ENTITY_DELETE:
{
print("ClientGame: deleting entity\n");
EntityDeleteMessage *delete_msg = static_cast<EntityDeleteMessage*>(msg.get());
int id = delete_msg->getData().entity_id;
for(unsigned int i = 0; i < entities.size(); i++)
if(entities[i]->getID() == id)
{
entities[i]->die();
entities.erase(entities.begin()+i);
break;
}
if(player_ship && id == player_ship->getID())
player_ship.reset();
//TODO do this properly
//.........这里部分代码省略.........
示例6: send
void protobuf_codec::send(conn_weak_ptr& conn, const MessagePtr& msg)
{
send(conn, msg.get());
}