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


C++ Connections::end方法代码示例

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


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

示例1: send

bool Connection::send( const Connections& connections, Packet& packet,
                       const void* data, const uint64_t dataSize,
                       const bool isLocked )
{
    if( connections.empty( ))
        return true;

    if( dataSize <= 8 ) // fits in existing packet
    {
        if( dataSize != 0 )
            memcpy( (char*)(&packet) + packet.size-8, data, dataSize );
        return send( connections, packet, isLocked );
    }

    const uint64_t headerSize  = packet.size - 8;
    const uint64_t size        = headerSize + dataSize;

    if( size > EQ_ASSEMBLE_THRESHOLD )
    {
        // OPT: lock the connection and use two send() to avoid big memcpy
        packet.size = size;
        bool success = true;

        for( Connections::const_iterator i= connections.begin(); 
             i<connections.end(); ++i )
        {        
            ConnectionPtr connection = *i;

            if( !isLocked )
                connection->lockSend();

            if( !connection->send( &packet, headerSize, true ) ||
                !connection->send( data, dataSize, true ))
            {
                success = false;
            }
            if( !isLocked )
                connection->unlockSend();    
        }
        return success;
    }

    char*          buffer = (char*)alloca( size );
    memcpy( buffer, &packet, packet.size-8 );
    memcpy( buffer + packet.size-8, data, dataSize );

    ((Packet*)buffer)->size = size;

    bool success = true;
    for( Connections::const_iterator i = connections.begin(); 
         i < connections.end(); ++i )
    {        
        ConnectionPtr connection = *i;
        if( !connection->send( buffer, size, isLocked ))
            success = false;
    }

    return success;
}
开发者ID:cstalder,项目名称:Equalizer,代码行数:59,代码来源:connection.cpp

示例2: windowLocker

void P2PConnectionsWindow::refreshConnections()
{
	Connections connections;
	// Effettua una copia per evitare una lock durante il check
	getConnections(connections);

	wxWindowUpdateLocker windowLocker(m_connectionsCtrl);

	uint32 connectionsCount = static_cast<uint32>(connections.size());
	uint32 connectionsLimit = getConnectionsLimit();

	bool pendingRefresh = false;

	for(Connections::iterator i = connections.begin(); i != connections.end(); ++i)
	{
		if(i->second->getRemoved())
		{
			if(i->second->isElapsed() || (connectionsCount > connectionsLimit))
			{
				doRemoveConnection(i->first);
				connectionsCount--;
			}
			else
			{
				markConnectionRemoved(i->first);
			}
		}
		else
		{
			refreshConnectionItem(i->first);
		}
	}
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: Block

	 void Block(const std::string& signalnamespace){
		//matching namespace? don't block global (non-namespaced) signals
		if(signalnamespace == this->signalnamespace && this->signalnamespace != ""){
			//signalbroker.InvokeSignal<OutputStreamView::LogHandler>("/log/output",
			//	"SignalSubsriber<" + childname + ">::Block("+this->signalnamespace+")");

			Connections::iterator itr = connections.begin();
			for(; itr!= connections.end(); itr++){
				itr->second.block();
			}
		}
	}
开发者ID:chikanamakalaka,项目名称:pacman-sdl,代码行数:12,代码来源:SignalSubscriber.hpp

示例4: get

 Buddy* get(const std::string &connectionName, const std::string &buddyName)
 {
     auto cn = p_connections.find(connectionName);
     if(p_connections.end() != cn)
     {
         auto buddy = cn->second.find(buddyName);
         if(cn->second.end() != buddy)
         {
             return &(buddy->second);
         }
     }
     return NULL;
 }
开发者ID:dwkimm01,项目名称:nclone,代码行数:13,代码来源:note.cpp

示例5: remove

 void remove(const std::string &connectionName, const std::string& buddyName)
 {
     auto cn = p_connections.find(connectionName);
     if(p_connections.end() != cn)
     {
         /*auto buddy = cn->second.find(buddyName);
         if(cn->second.end() != buddy)
         {
            cn->second.erase(buddy);
         }*/
         cn->second.erase(buddyName);
     }
 }
开发者ID:dwkimm01,项目名称:nclone,代码行数:13,代码来源:note.cpp

示例6: _createThread

void ConnectionSet::_createThread( const Connections& connections )
{
    Thread* thread = new Thread( this );
    for ( ConnectionsCIter it = connections.begin(); 
          it != connections.end(); 
          ++it )
    {
        ConnectionPtr connection = *it;
        thread->set.addConnection( connection );
    }

    _impl->threads.push_back( thread );
    thread->start();
}
开发者ID:rttag,项目名称:Collage,代码行数:14,代码来源:connectionSet.cpp

示例7: createBlockRow

            void
            createBlockRow(size_t i, const Connections& conn, size_t ndof) {
                assert (ndof == 1);            (void) ndof;
                assert (i    == i_prev_ + 1);  (void) i   ;

                ISTLTypeDetails::ScalarBCRSMatrix::CreateIterator ci(mat_, i);

                for (typename Connections::const_iterator
                         c = conn.begin(), e = conn.end(); c != e; ++c) {
                    ci.insert(*c);
                }

                ++i_prev_;
                ++ci;
            }
开发者ID:akva2,项目名称:opm-porsol,代码行数:15,代码来源:BCRSMatrixBlockAssembler.hpp

示例8: removeFromConnectionTable

void removeFromConnectionTable(int socketDescriptor){
	/* Remove the user with the closed socket */
	Connections::iterator it = conn.begin();
	while(it!=conn.end()){
		if(it->second == socketDescriptor){
			
			#ifdef __INFO__
			std::cout<<"\""<<it->first<<"\" went offline on socket "<<socketDescriptor<<"."<<std::endl;
			#endif

			conn.erase(it);
			break;
		}
		++it;
	}
}
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:16,代码来源:Server.cpp

示例9: getOnlineList

/* 
 * Returns list of online nicknames as
 * ONLINE: <user1> : <user2> : ...
 */
std::string getOnlineList(std::string curUser){
	std::string response = "ONLINE: ";
	Connections::iterator it = conn.begin();

	while(it!=conn.end()){
		if(it->first!=curUser){
			bool online = isOnline(it->first);
			if(online){
				response += it->first;
				response += ":";
			}
		}
		++it;
	}

	return response;
}
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:21,代码来源:Server.cpp

示例10: getFromConnectionTable

/* Get socket descriptor of the username */
int getFromConnectionTable(std::string username){
	Connections::iterator it = conn.find(username);
	if(it == conn.end())
		return -1;
	return it->second;
}
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:7,代码来源:Server.cpp

示例11: processRequest

/*
 * Parse incoming data
 * Types of messages and their responses are:
 *					NEW: <from>
 *						Response --> NEW: <status>
 *					CHNAME: <old> : <new>
 *						Response --> CHNAME: <status>
 * 					QUERY: <from>
 *						Response --> ONLINE: <user1> : <user2> : <user3> : ....
 *					SEND: <from> : <to> : <message>
 *						Response --> SENT: <to> : <statusMessage>
 *					BCAST: <from> : <message>
 *						Response --> SENT: <from> : <status>
 *					
 *					/toclient/ RECV: <from> : <message>
 */
void processRequest(int fromSocket, char* stream){
	std::vector<std::string> tokens;

	char* dump = strdup(stream);												/* Create a duplicate stream */
	splitCharStream(dump, DELIM, 1, &tokens);									/* Retrieve the kind of message */
	delete dump;

	std::string reqType = tokens[0];

	int TYPE_FLAG = -1, delimCount=-1;
	if(reqType=="CHNAME"){
		TYPE_FLAG = TYPE_CHNAME;
		delimCount = 1;
	}
	else if(reqType=="NEW"){
		TYPE_FLAG = TYPE_NEW;
		delimCount = 0;
	}
	else if(reqType=="QUERY"){
		TYPE_FLAG = TYPE_QUERY;
		delimCount = 0;
	}
	else if(reqType=="SEND"){
		TYPE_FLAG = TYPE_SEND;
		delimCount = 2;
	}
	else if(reqType=="BCAST"){
		TYPE_FLAG = TYPE_BCAST;
		delimCount = 1;
	}

	if(TYPE_FLAG==-1)
		return;
	
	#ifdef __DEBUG__
	std::cout<<TYPE_FLAG<<" --- ";
	#endif

	splitCharStream(strdup(tokens[1].c_str()), DELIM, delimCount, &tokens);		/* Based on kind retrieve other param list */
	
	std::string fromUser = tokens[0];
	std::string toUser, message;
	if(TYPE_FLAG == TYPE_CHNAME){
		toUser = tokens[1];
		#ifdef __INFO__
		std::cout<<"\""<<fromUser<<"\" changing name to \""<<toUser<<"\"."<<std::endl;
		#endif

		int curSock = getFromConnectionTable(fromUser);
		std::string reply = "CHNAME:"+toUser+":";
		if(curSock==-1){
			reply += "fail";
		}
		else{
			curSock = getFromConnectionTable(toUser);
			if(curSock==-1){
				removeFromConnectionTable(fromSocket);
				addToConnectionTable(toUser, fromSocket);
				reply += "success";
			}
			else{
				reply += "duplicate";
			}
		}
		int s = send(fromSocket, reply.c_str(), reply.length(), 0);
		if(s<0){
			ERROR = E_SEND;
			error_message = "Unable to send query reply.";

			#ifdef __DEBUG__
			std::cout<<error_message<<std::endl;
			#endif
		}	
	}
	else if(TYPE_FLAG == TYPE_NEW){
		#ifdef __INFO__
		std::cout<<"\""<<fromUser<<"\" new registration."<<std::endl;
		#endif

		int oldSock = getFromConnectionTable(fromUser);
		std::string reply = "duplicate";
		if(oldSock==-1){
			addToConnectionTable(fromUser, fromSocket);								/* Add user socket pair to table */
			reply = "registered";
//.........这里部分代码省略.........
开发者ID:ChinmayJindal,项目名称:GossipBox,代码行数:101,代码来源:Server.cpp


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