本文整理汇总了C++中HTTPRequest::GetParam方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPRequest::GetParam方法的具体用法?C++ HTTPRequest::GetParam怎么用?C++ HTTPRequest::GetParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::GetParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RPC
bool Port::RPC( const HTTPRequest &request, const std::string &cat, const std::string &action )
{
if( action == "set" )
{
int port_num;
std::string name;
int source_id;
if( !request.GetParam( "port_num", port_num ))
return false;
this->port_num = port_num;
if( !request.GetParam( "name", name ))
return false;
this->name = name;
if( !request.GetParam( "source_id", source_id ))
return false;
if( source && ( source_id == -1 || source_id != source->GetKey( )))
{
source->RemovePort( this );
source = NULL;
}
if( source_id != -1 )
{
if( !source || ( source && source_id != source->GetKey( )))
{
source = TVDaemon::Instance( )->GetSource( source_id );
source->AddPort( this );
SetSource( source );
}
}
request.Reply( HTTP_OK );
return true;
}
request.NotFound( "Port::RPC unknown action '%s'", action.c_str( ));
return false;
}
示例2: RPC
bool Adapter::RPC( const HTTPRequest &request, const std::string &cat, const std::string &action )
{
if( cat == "port" or cat == "frontend" )
{
std::string t;
if( !request.GetParam( "frontend_id", t ))
return false;
int i = atoi( t.c_str( ));
if( i >= 0 && i < frontends.size( ))
{
return frontends[i]->RPC( request, cat, action );
}
}
request.NotFound( "RPC: unknown action '%s'", action.c_str( ));
return false;
}
示例3: RPC
bool Frontend::RPC( const HTTPRequest &request, const std::string &cat, const std::string &action )
{
if( cat == "port" )
{
int port_id;
if( !request.GetParam( "port_id", port_id ))
return false;
LockPorts( );
std::map<int, Port *>::iterator it = ports.find( port_id );
if( it == ports.end( ))
{
LogError( "Port %d not found", port_id );
return false;
}
bool ret = it->second->RPC( request, cat, action );
UnlockPorts( );
return ret;
}
if( action == "create_port" )
{
int port_num;
if( !request.GetParam( "port_num", port_num ))
return false;
std::string name;
if( !request.GetParam( "name", name ))
return false;
int source_id;
if( !request.GetParam( "source_id", source_id ))
return false;
Port *port = AddPort( name, port_num );
if( port == NULL )
{
request.NotFound( "Port with number %d already exists", port_num );
return false;
}
Source *source = TVDaemon::Instance( )->GetSource( source_id );
if( !source )
LogError( "Source not found: %d", source_id );
else
{
source->AddPort( port );
port->SetSource( source );
}
request.Reply( HTTP_OK, port->GetKey( ));
return true;
}
if( action == "delete_port" )
{
int port_id;
if( !request.GetParam( "port_id", port_id ))
return false;
LockPorts( );
std::map<int, Port *>::iterator it = ports.find( port_id );
if( it == ports.end( ))
{
LogError( "Port not found: %d", port_id );
UnlockPorts( );
return false;
}
it->second->Delete( );
delete it->second;
ports.erase( it );
UnlockPorts( );
return true;
}
request.NotFound( "RPC unknown action: '%s'", action.c_str( ));
return false;
}