本文整理汇总了C++中co::ICommand类的典型用法代码示例。如果您正苦于以下问题:C++ ICommand类的具体用法?C++ ICommand怎么用?C++ ICommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICommand类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _cmdExit
bool Client::_cmdExit( co::ICommand& command )
{
_impl->running = false;
// Close connection here, this is the last command we'll get on it
command.getLocalNode()->disconnect( command.getRemoteNode( ));
return true;
}
示例2: dispatchCommand
bool Client::dispatchCommand( co::ICommand& command )
{
LBVERB << "dispatch " << command << std::endl;
if( command.getCommand() >= co::CMD_NODE_CUSTOM &&
command.getCommand() < CMD_SERVER_CUSTOM )
{
co::NodePtr node = command.getRemoteNode();
return node->co::Dispatcher::dispatchCommand( command );
}
return co::LocalNode::dispatchCommand( command );
}
示例3: _cmdChooseConfigReply
//---------------------------------------------------------------------------
// command handlers
//---------------------------------------------------------------------------
bool Server::_cmdChooseConfigReply( co::ICommand& command )
{
co::LocalNodePtr localNode = command.getLocalNode();
const UUID configID = command.get< UUID >();
const uint32_t requestID = command.get< uint32_t >();
LBVERB << "Handle choose config reply " << command << " req " << requestID
<< " id " << configID << std::endl;
if( configID == UUID::ZERO )
{
localNode->serveRequest( requestID, (void*)0 );
return true;
}
const std::string connectionData = command.get< std::string >();
const Configs& configs = getConfigs();
for( Configs::const_iterator i = configs.begin(); i != configs.end(); ++i )
{
Config* config = *i;
if( config->getID() == configID )
{
config->setupServerConnections( connectionData );
localNode->serveRequest( requestID, config );
return true;
}
}
LBUNIMPLEMENTED
return true;
}
示例4: _cmdShutdownReply
bool Server::_cmdShutdownReply( co::ICommand& command )
{
co::LocalNodePtr localNode = command.getLocalNode();
const uint32_t requestID = command.get< uint32_t >();
const bool result = command.get< bool >();
localNode->serveRequest( requestID, result );
return true;
}
示例5: _cmdData
bool _cmdData( co::ICommand& command )
{
TEST( _gotAsync );
command.getNode()->send( CMD_DATA_REPLY )
<< command.get< uint32_t >() << ++_counter;
TEST( command.get< std::string >() == payload );
return true;
}
示例6: _cmdReleaseConfig
bool Server::_cmdReleaseConfig( co::ICommand& command )
{
UUID configID = command.get< UUID >();
uint32_t requestID = command.get< uint32_t >();
LBVERB << "Handle release config " << command << " config " << configID
<< std::endl;
co::NodePtr node = command.getNode();
Config* config = 0;
const Configs& configs = getConfigs();
for( Configs::const_iterator i = configs.begin();
i != configs.end() && !config; ++i )
{
Config* candidate = *i;
if( candidate->getID() == configID )
config = candidate;
}
if( !config )
{
LBWARN << "Release request for unknown config" << std::endl;
node->send( fabric::CMD_SERVER_RELEASE_CONFIG_REPLY ) << requestID;
return true;
}
if( config->isRunning( ))
{
LBWARN << "Release of running configuration" << std::endl;
config->exit(); // Make sure config is exited
}
const uint32_t destroyRequestID = registerRequest();
node->send( fabric::CMD_SERVER_DESTROY_CONFIG )
<< config->getID() << destroyRequestID;
waitRequest( destroyRequestID );
#ifdef EQUALIZER_USE_HWSD
if( config->isAutoConfig( ))
{
LBASSERT( _admins.empty( ));
config->deregister();
config::Server::release( config );
}
else
#endif
{
ConfigRestoreVisitor restore;
config->accept( restore );
config->commit();
}
node->send( fabric::CMD_SERVER_RELEASE_CONFIG_REPLY ) << requestID;
LBLOG( lunchbox::LOG_ANY ) << "----- Released Config -----" << std::endl;
return true;
}
示例7: _cmdMap
bool Server::_cmdMap( co::ICommand& command )
{
co::NodePtr node = command.getNode();
_admins.push_back( node );
const Configs& configs = getConfigs();
for( Configs::const_iterator i = configs.begin(); i != configs.end(); ++i )
{
Config* config = *i;
node->send( fabric::CMD_SERVER_CREATE_CONFIG )
<< co::ObjectVersion( config ) << LB_UNDEFINED_UINT32;
}
node->send( fabric::CMD_SERVER_MAP_REPLY ) << command.get< uint32_t >();
return true;
}
示例8: _cmdShutdown
bool Server::_cmdShutdown( co::ICommand& command )
{
const uint32_t requestID = command.get< uint32_t >();
co::NodePtr node = command.getNode();
if( !_admins.empty( ))
{
LBWARN << "Ignoring shutdown request, " << _admins.size()
<< " admin clients connected" << std::endl;
node->send( fabric::CMD_SERVER_SHUTDOWN_REPLY ) << requestID << false;
return true;
}
const Configs& configs = getConfigs();
for( Configs::const_iterator i = configs.begin(); i != configs.end(); ++i )
{
Config* candidate = *i;
if( candidate->isUsed( ))
{
LBWARN << "Ignoring shutdown request due to used config"
<< std::endl;
node->send( fabric::CMD_SERVER_SHUTDOWN_REPLY )
<< requestID << false;
return true;
}
}
LBINFO << "Shutting down server" << std::endl;
_running = false;
node->send( fabric::CMD_SERVER_SHUTDOWN_REPLY ) << requestID << true;
#ifndef WIN32
// WAR for 2874188: Lockup at shutdown
lunchbox::sleep( 100 );
#endif
return true;
}
示例9: _cmdUnmap
bool Server::_cmdUnmap( co::ICommand& command )
{
co::NodePtr node = command.getNode();
co::Nodes::iterator i = stde::find( _admins, node );
LBASSERT( i != _admins.end( ));
if( i != _admins.end( ))
{
_admins.erase( i );
const Configs& configs = getConfigs();
for( Configs::const_iterator j = configs.begin();
j != configs.end(); ++j )
{
Config* config = *j;
node->send( fabric::CMD_SERVER_DESTROY_CONFIG )
<< config->getID() << LB_UNDEFINED_UINT32;
}
}
node->send( fabric::CMD_SERVER_UNMAP_REPLY ) << command.get< uint32_t >();
return true;
}
示例10: _cmdReleaseConfigReply
bool Server::_cmdReleaseConfigReply( co::ICommand& command )
{
co::LocalNodePtr localNode = command.getLocalNode();
localNode->serveRequest( command.get< uint32_t >( ));
return true;
}
示例11: _cmdChooseConfig
bool Server::_cmdChooseConfig( co::ICommand& command )
{
const uint32_t requestID = command.get< uint32_t >();
const fabric::ConfigParams& params = command.get< fabric::ConfigParams >();
LBVERB << "Handle choose config " << command << " req " << requestID
<< " renderer " << params.getWorkDir() << '/'
<< params.getRenderClient() << std::endl;
Config* config = 0;
const Configs& configs = getConfigs();
for( ConfigsCIter i = configs.begin(); i != configs.end() && !config; ++i )
{
Config* candidate = *i;
const float version = candidate->getFAttribute( Config::FATTR_VERSION );
LBASSERT( version == 1.2f );
if( !candidate->isUsed() && version == 1.2f )
config = candidate;
}
#ifdef EQUALIZER_USE_HWSD
if( !config )
{
const std::string& configFile = command.get< std::string >();
config = config::Server::configure( this, configFile, params );
if( config )
{
config->register_();
LBINFO << "Configured\n" << *this << std::endl;
}
}
#endif
co::NodePtr node = command.getNode();
if( !config )
{
node->send( fabric::CMD_SERVER_CHOOSE_CONFIG_REPLY )
<< UUID() << requestID;
return true;
}
ConfigBackupVisitor backup;
config->accept( backup );
config->setApplicationNetNode( node );
config->setWorkDir( params.getWorkDir( ));
config->setRenderClient( params.getRenderClient( ));
config->commit();
node->send( fabric::CMD_SERVER_CREATE_CONFIG )
<< co::ObjectVersion( config ) << LB_UNDEFINED_UINT32;
server::Node* appNode = config->findApplicationNode();
const co::ConnectionDescriptions& descs =
appNode->getConnectionDescriptions();
if( config->getNodes().size() > 1 )
{
if( descs.empty() && node->getConnectionDescriptions().empty( ))
{
LBWARN << "Likely misconfiguration: Neither the application nor the"
<< " config file has a connection for this multi-node "
<< "config. Render clients will be unable to communicate "
<< "with the application process." << std::endl;
}
if( getConnectionDescriptions().empty( ))
{
LBWARN << "Likely misconfiguration: The server has no listening "
<< "connection for this multi-node config. Render clients "
<< "will be unable to communicate with the server."
<< std::endl;
}
}
node->send( fabric::CMD_SERVER_CHOOSE_CONFIG_REPLY )
<< config->getID() << requestID << co::serialize( descs );
return true;
}
示例12: _cmdSync
bool _cmdSync( co::ICommand& command )
{
TEST( _gotAsync );
ackRequest( command.getNode(), command.get< uint32_t >( ));
return true;
}