当前位置: 首页>>代码示例>>C++>>正文


C++ HTTPRequest::GetParam方法代码示例

本文整理汇总了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;
}
开发者ID:neolynx,项目名称:tvdaemon,代码行数:42,代码来源:Port.cpp

示例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;
}
开发者ID:wiplug,项目名称:tvdaemon,代码行数:17,代码来源:Adapter.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:75,代码来源:


注:本文中的HTTPRequest::GetParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。