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


C++ ConnectionPtr::close方法代码示例

本文整理汇总了C++中ConnectionPtr::close方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::close方法的具体用法?C++ ConnectionPtr::close怎么用?C++ ConnectionPtr::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectionPtr的用法示例。


在下文中一共展示了ConnectionPtr::close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _removeConnection

void LocalNode::_removeConnection( ConnectionPtr connection )
{
    EQASSERT( connection.isValid( ));

    _incoming.removeConnection( connection );

    void* buffer( 0 );
    uint64_t bytes( 0 );
    connection->getRecvData( &buffer, &bytes );
    EQASSERTINFO( !connection->isConnected() || buffer, *connection );
    EQASSERT( !buffer || bytes == sizeof( uint64_t ));

    if( !connection->isClosed( ))
        connection->close(); // cancels pending IO's
    delete reinterpret_cast< uint64_t* >( buffer );
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:16,代码来源:localNode.cpp

示例2: ObjectNotExistException

RouterIPtr
SessionRouterI::getRouterImpl(const ConnectionPtr& connection, const Ice::Identity& id, bool close) const
{
    if(_destroy)
    {
        throw ObjectNotExistException(__FILE__, __LINE__);
    }

    map<ConnectionPtr, RouterIPtr>& routers = const_cast<map<ConnectionPtr, RouterIPtr>&>(_routersByConnection);

    if(_routersByConnectionHint != routers.end() && _routersByConnectionHint->first == connection)
    {
        _routersByConnectionHint->second->updateTimestamp();
        return _routersByConnectionHint->second;
    }

    map<ConnectionPtr, RouterIPtr>::iterator p = routers.find(connection);

    if(p != routers.end())
    {
        _routersByConnectionHint = p;
        p->second->updateTimestamp();
        return p->second;
    }
    else if(close)
    {
        if(_rejectTraceLevel >= 1)
        {
            Trace out(_instance->logger(), "Glacier2");
            out << "rejecting request, no session is associated with the connection.\n";
            out << "identity: " << identityToString(id);
        }
        connection->close(ICE_SCOPED_ENUM(ConnectionClose, Forcefully));
        throw ObjectNotExistException(__FILE__, __LINE__);
    }
    return 0;
}
开发者ID:yuanbaopapa,项目名称:ice,代码行数:37,代码来源:SessionRouterI.cpp

示例3: send

void WtReply::send(const std::string& text, CallbackFunction callBack,
		   bool responseComplete)
{
  ConnectionPtr connection = getConnection();

  if (!connection)
    return;

  fetchMoreDataCallback_ = callBack;

  bool webSocket = request().webSocketVersion >= 0;

  if (webSocket) {
    if (!sendingMessages_) {
      /*
       * This finishes the server handshake. For 00-protocol, we copy
       * the computed handshake nonce in the output.
       */
      nextCout_.assign(cin_mem_.str());

      sendingMessages_ = true;
    } else {
      /*
       * This should be sent as a websocket message.
       */
      if (text.empty()) {
	LOG_DEBUG("ws: closed by app");

	/*
	 * FIXME: send a close frame
	 */
	connection->close();
	return;
      }

      LOG_DEBUG("ws: sending a message, length = " << (long long)text.length());

      nextCout_.clear();

      switch (request().webSocketVersion) {
      case 0:
	nextCout_ += (char)0;
	nextCout_ += text;
	nextCout_ += (char)0xFF;

	break;
      case 7:
      case 8:
      case 13:
	{
	  nextCout_ += (char)0x81;

	  std::size_t payloadLength = text.length();

	  if (payloadLength < 126)
	    nextCout_ += (char)payloadLength;
	  else if (payloadLength < (1 << 16)) {
	    nextCout_ += (char)126;
	    nextCout_ += (char)(payloadLength >> 8);
	    nextCout_ += (char)(payloadLength);
	  } else {
	    nextCout_ += (char)127;
	    for (unsigned i = 0; i < 8; ++i)
	      nextCout_ += (char)(payloadLength >> ((7-i) * 8));
	  }

	  nextCout_ += text;
	}
	break;
      default:
	LOG_ERROR("ws: encoding for version " <<
		  request().webSocketVersion << " is not implemented");
	connection->close();
	return;
      }
    }
开发者ID:bytemaster,项目名称:wt-1,代码行数:76,代码来源:WtReply.C


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