本文整理汇总了C++中Connections::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Connections::begin方法的具体用法?C++ Connections::begin怎么用?C++ Connections::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connections
的用法示例。
在下文中一共展示了Connections::begin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
}
示例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();
}
}
}
示例4: _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();
}
示例5: 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;
}
示例6: 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;
}
}
示例7: 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;
}
示例8: processRequest
//.........这里部分代码省略.........
if(oldSock==-1){
addToConnectionTable(fromUser, fromSocket); /* Add user socket pair to table */
reply = "registered";
}
#ifdef __INFO__
std::cout<<"\""<<fromUser<<"\" reg. status: "<<reply<<"."<<std::endl;
#endif
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_QUERY){
#ifdef __INFO__
std::cout<<"\""<<fromUser<<"\" queried."<<std::endl;
#endif
std::string onlineList = getOnlineList(fromUser);
int s = send(fromSocket, onlineList.c_str(), onlineList.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_SEND){
toUser = tokens[1];
message = tokens[2];
#ifdef __INFO__
std::cout<<"\""<<fromUser<<"\" sending message to \""<<toUser<<"\"."<<std::endl;
#endif
/* Send message to desired target username */
int status = sendMessage(toUser, fromUser, message);
std::string reply = "SENT: "+toUser+" : ";
if(status==-1){
reply += error_message;
#ifdef __DEBUG__
std::cout<<"\""<<fromUser<<"\" could not send a message to \""<<toUser<<"\". "<<std::endl;
#endif
}
else{
reply += "success";
#ifdef __DEBUG__
std::cout<<"\""<<fromUser<<"\" sent a message to \""<<toUser<<"\"."<<std::endl;
#endif
}
/* Report back to the sender */
int s = send(fromSocket, reply.c_str(), reply.length(), 0);
if(s<0){
ERROR = E_SEND;
error_message = "Unable to send message status.";
#ifdef __DEBUG__
std::cout<<error_message<<std::endl;
#endif
}
}
else if(TYPE_FLAG == TYPE_BCAST){
message = tokens[1];
std::string bcast = "RECV:"+fromUser+":"+message;
#ifdef __INFO__
std::cout<<"Broadcast from \""+fromUser+"\" : "<<message<<std::endl;
#endif
int status;
Connections::iterator it = conn.begin();
while(it!=conn.end()){
if(it->first != fromUser){
status = send(it->second, bcast.c_str(), bcast.length(), 0 );
}
++it;
}
std::string reply = "SENT:"+fromUser+":b_success";
/* Report back to the broadcaster */
int s = send(fromSocket, reply.c_str(), reply.length(), 0);
if(s<0){
ERROR = E_SEND;
error_message = "Unable to send message status.";
#ifdef __DEBUG__
std::cout<<error_message<<std::endl;
#endif
}
}
}