Logo Search packages:      
Sourcecode: verlihub version File versions

void nDirectConnect::cServerDC::SendToAll ( string &  data,
int  cm,
int  cM 
)

find user with given nick, if not there return NULL send the same data to every user

send the same data to every user

Definition at line 472 of file cserverdc.cpp.

References nUtils::cMeanFrequency< T, max_size >::Insert(), cObj::Log(), cObj::LogStream(), nDirectConnect::cConnDC::mGeoZone, nDirectConnect::cUserBase::mInList, mNetOutLog, nDirectConnect::cConnDC::mpUser, cObj::msLogLevel, nServer::cAsyncSocketServer::mTime, nServer::cAsyncConn::mWritable, nServer::cAsyncConn::ok, and nServer::cAsyncConn::Write().

{
      cConnDC *conn;
      tCLIt i;
      int size = data.size();

      // prepare data
      if(size >= MAX_SEND_SIZE-1)
      {
            if(Log(2))
                  LogStream() << "Truncating too long message from: "
                        << data.size() << " to " << MAX_SEND_SIZE -1 << " Message starts with: " << data.substr(0,10) << endl;
            data.resize( MAX_SEND_SIZE -1,' ');
            size = MAX_SEND_SIZE -1;
      }
      if(data[data.size()-1] !='|')
      {
            data.append("|");
            size ++;
      }

      int count=0;
      for(i=mConnList.begin(); i!= mConnList.end(); i++)
      {
            conn=(cConnDC *)(*i);
            if(conn && conn->ok && conn->mWritable && conn->mpUser && conn->mpUser->mInList)
            {
                  conn->Write(data, true);
                  mUploadZone[conn->mGeoZone].Insert(mTime,data.size());
                  ++count;
            }
      }
      if(Log(5)) LogStream() << "ALL << " << data.substr(0,100) << endl;
      if(msLogLevel >= 3)
            mNetOutLog << ((unsigned long)count) *data.size() << " "
                  << data.size() << " "
                  << count << " " << data.substr(0,10) << endl;
}


Generated by  Doxygen 1.6.0   Back to index