Esempio n. 1
0
void AdcHub::on(Failed, const string& aLine) throw() { 
	if(getMe())
		ClientManager::getInstance()->putUserOffline(getMe());
	setMe(NULL);
	state = STATE_PROTOCOL;
	fire(ClientListener::Failed(), this, aLine);
}
Esempio n. 2
0
void AdcHub::info() {
	if(state != STATE_IDENTIFY && state != STATE_NORMAL)
		return;
	if(!getMe())
		return;

	string minf = "BINF " + getMe()->getCID().toBase32();
	unsigned size = minf.size();
	string tmp;

	StringMapIter i;
#define ADDPARAM(var, content) \
	tmp = content; \
	if((i = lastInfoMap.find(var)) != lastInfoMap.end()) { \
		if(i->second != tmp) { \
			if(tmp.empty()) \
				lastInfoMap.erase(i); \
			else \
				i->second = tmp; \
			minf += var + tmp; \
		} \
	} else if(!tmp.empty()) { \
		minf += var + tmp; \
		lastInfoMap[var] = tmp; \
	}

	ADDPARAM(" NI", Command::escape(getNick()));
	ADDPARAM(" DE", Command::escape(getDescription()));
	ADDPARAM(" SL", Util::toString(SETTING(SLOTS)));
	ADDPARAM(" SS", ShareManager::getInstance()->getShareSizeString());
	ADDPARAM(" HN", Util::toString((int64_t)counts.normal));
	ADDPARAM(" HR", Util::toString((int64_t)counts.registered));
	ADDPARAM(" HO", Util::toString((int64_t)counts.op));
	ADDPARAM(" VE", "++\\ " VERSIONSTRING);
	if(SETTING(CONNECTION_TYPE) == SettingsManager::CONNECTION_ACTIVE) {
		ADDPARAM(" I4", "0.0.0.0");
		ADDPARAM(" U4", Util::toString(SETTING(IN_PORT)));
	} else {
		ADDPARAM(" I4", "");
		ADDPARAM(" U4", "");
	}

#undef ADDPARAM

	if(minf.size() != size) {
		minf += "\n";
		send(minf);
	}
}
Esempio n. 3
0
UserPtr ClientManager::getUser(const CID& cid) noexcept {
	Lock l(cs);
	auto ui = users.find(cid);
	if(ui != users.end()) {
		return ui->second;
	}

	if(cid == getMe()->getCID()) {
		return getMe();
	}

	UserPtr p(new User(cid));
	users.emplace(cid, p);
	return p;
}
Esempio n. 4
0
void AdcHub::password(const string& pwd) { 
	if(state != STATE_VERIFY)
		return;
	if(!salt.empty()) {
		static const int SALT_SIZE = 192/8;
		u_int8_t buf[SALT_SIZE];
		Encoder::fromBase32(salt.c_str(), buf, SALT_SIZE);
		const string& x = pwd;
		TigerHash th;
		th.update(getMe()->getCID().getData(), CID::SIZE);
		th.update(x.data(), x.length());
		th.update(buf, SALT_SIZE);
		send("HPAS " + getMe()->getCID().toBase32() + " " + Encoder::toBase32(th.finalize(), TigerHash::HASH_SIZE) + "\n");
		salt.clear();
	}
}
Esempio n. 5
0
void UserConnection::handlePM(const AdcCommand& c, bool echo) noexcept{
	const string& message = c.getParam(0);
	OnlineUserPtr peer = nullptr;
	OnlineUserPtr me = nullptr;

	auto cm = ClientManager::getInstance();
	{
		RLock l(cm->getCS());
		peer = cm->findOnlineUser(user->getCID(), getHubUrl());
		//try to use the same hub so nicks match to a hub, not the perfect solution for CCPM, nicks keep changing when hubs go offline.
		if(peer && peer->getHubUrl() != hubUrl) 
			setHubUrl(peer->getHubUrl());
		me = cm->findOnlineUser(cm->getMe()->getCID(), getHubUrl());
	}

	if (!me || !peer){ //ChatMessage cant be formatted without the OnlineUser!
		disconnect(true);
		return;
	}

	if (echo) {
		std::swap(peer, me);
	}

	string tmp;

	auto msg = make_shared<ChatMessage>(message, peer, me, peer);
	if (c.getParam("TS", 1, tmp)) {
		msg->setTime(Util::toInt64(tmp));
	}

	msg->setThirdPerson(c.hasFlag("ME", 1));
	fire(UserConnectionListener::PrivateMessage(), this, msg);
}
Esempio n. 6
0
void ClientManager::sendUDP(AdcCommand& cmd, const OnlineUser& user) {
	dcassert(cmd.getType() == AdcCommand::TYPE_UDP);
	if(!user.getIdentity().isUdpActive()) {
		cmd.setType(AdcCommand::TYPE_DIRECT);
		cmd.setTo(user.getIdentity().getSID());
		const_cast<Client&>(user.getClient()).send(cmd);
	} else {
		sendUDP(user.getIdentity().getIp(), user.getIdentity().getUdpPort(), cmd.toString(getMe()->getCID()));
	}
}
Esempio n. 7
0
    bool replHandshake(DBClientConnection *conn) {
        BSONObj me;
        LOCK_REASON(lockReason, "repl: handshake");
        try {
            Client::ReadContext ctx("local", lockReason);
            getMe(me);
        }
        catch (RetryWithWriteLock &e) {
            Client::WriteContext ctx("local", lockReason);
            getMe(me);
        }

        BSONObjBuilder cmd;
        cmd.appendAs( me["_id"] , "handshake" );
        if (theReplSet) {
            cmd.append("member", theReplSet->selfId());
        }

        BSONObj res;
        bool ok = conn->runCommand( "admin" , cmd.obj() , res );
        // ignoring for now on purpose for older versions
        LOG(ok ? 1 : 0) << "replHandshake res not: " << ok << " res: " << res << endl;
        return true;
    }
Esempio n. 8
0
void AdcHub::search(int aSizeMode, int64_t aSize, int aFileType, const string& aString) { 
	if(state != STATE_NORMAL)
		return;
	string strtmp;
	strtmp += "BSCH " + getMe()->getCID().toBase32() + " ";
	if(aSizeMode == SearchManager::SIZE_ATLEAST) {
		strtmp += ">=" + Util::toString(aSize) + " ";
	} else if(aSizeMode == SearchManager::SIZE_ATMOST) {
		strtmp += "<=" + Util::toString(aSize) + " ";
	}
	StringTokenizer<string> st(aString, ' ');
	string tmp;
	for(StringIter i = st.getTokens().begin(); i != st.getTokens().end(); ++i) {
		strtmp += "++" + Command::escape(*i) + " ";
	}
	strtmp[strtmp.length() - 1] = '\n';
	send(strtmp);
}
Esempio n. 9
0
void AdcHub::handle(Command::MSG, Command& c) throw() {
	if(c.getFrom().isZero() || c.getParameters().empty())
		return;
	User::Ptr p = ClientManager::getInstance()->getUser(c.getFrom(), false);
	if(!p)
		return;
	if(c.getParameters().size() == 2 && c.getParameters()[1] == "PM") { // add PM<group-cid> as well
		const string& msg = c.getParameters()[0];
		if(c.getFrom() == getMe()->getCID()) {
			p = ClientManager::getInstance()->getUser(c.getTo(), false);
			if(!p)
				return;
		}
		fire(ClientListener::PrivateMessage(), this, p, msg);
	} else {
		string msg = '<' + p->getNick() + "> " + c.getParameters()[0];
		fire(ClientListener::Message(), this, msg);
	}		
}
Esempio n. 10
0
void UserConnection::handlePM(const AdcCommand& c, bool echo) noexcept {
	auto message = c.getParam(0);

	auto cm = ClientManager::getInstance();
	auto lock = cm->lock();
	auto peer = cm->findOnlineUser(user->getCID(), hubUrl);
	auto me = cm->findOnlineUser(cm->getMe()->getCID(), hubUrl);
	// null pointers allowed here as the conn may be going on without hubs.

	if(echo) {
		std::swap(peer, me);
	}

	if(peer && peer->getIdentity().noChat())
		return;

	if(PluginManager::getInstance()->runHook(HOOK_CHAT_PM_IN, peer, message))
		return;

	string tmp;
	fire(UserConnectionListener::PrivateMessage(), this, ChatMessage(message, peer, me, peer,
		c.hasFlag("ME", 1), c.getParam("TS", 1, tmp) ? Util::toInt64(tmp) : 0));
}
Esempio n. 11
0
void AdcHub::handle(Command::INF, Command& c) throw() {
	if(c.getFrom().isZero() || c.getParameters().empty())
		return;

	User::Ptr u = ClientManager::getInstance()->getUser(c.getFrom(), this, true);

	int op = 0;
	int reg = 0;
	int norm = 0;
	string ve;
	int sl = 0;

	for(StringIterC i = c.getParameters().begin(); i != c.getParameters().end(); ++i) {
		if(i->length() < 2)
			continue;

		if(i->compare(0, 2, "NI") == 0) {
			u->setNick(i->substr(2));
		} else if(i->compare(0, 2, "HU") == 0) {
			hub = u;
		} else if(i->compare(0, 2, "DE") == 0) {
			u->setDescription(i->substr(2));
		} else if(i->compare(0, 2, "I4") == 0) {
			u->setIp(i->substr(2));
		} else if(i->compare(0, 2, "SS") == 0) {
			u->setBytesShared(i->substr(2));
		} else if(i->compare(0, 2, "VE") == 0) {
			ve = i->substr(2);
		} else if(i->compare(0, 2, "EM") == 0) {
			u->setEmail(i->substr(2));
		} else if(i->compare(0, 2, "OP") == 0) {
			if(i->length() == 2) {
				u->unsetFlag(User::OP);
			} else {
				u->setFlag(User::OP);
			}
		} else if(i->compare(0, 2, "HO") == 0) {
			op = Util::toInt(i->substr(2));
		} else if(i->compare(0, 2, "HR") == 0) {
			reg = Util::toInt(i->substr(2));
		} else if(i->compare(0, 2, "HN") == 0) {
			norm = Util::toInt(i->substr(2));
		} else if(i->compare(0, 2, "SL") == 0) {
			sl = Util::toInt(i->substr(2));
		} else if(i->compare(0, 2, "BO") == 0) {
			if(i->length() == 2) {
				u->unsetFlag(User::BOT);
			} else {
				u->setFlag(User::BOT);
			}
		} else if(i->compare(0, 2, "HI") == 0) {
			if(i->length() == 2) {
				u->unsetFlag(User::HIDDEN);
			} else {
				u->setFlag(User::HIDDEN);
			}
		} else if(i->compare(0, 2, "HU") == 0) {
			if(i->length() == 2) {
				u->unsetFlag(User::HUB);
			} else {
				u->setFlag(User::HUB);
			}
		}
	}

	if(!ve.empty()) {
		if(ve.find(' ') != string::npos) {
			ve.insert(ve.find(' ') + 1, "V:");
		}
		u->setTag("<" + ve + ",M:" + string(u->getIp().empty() ? "P" : "A") + ",H:" + Util::toString(norm) + "/" + 
			Util::toString(reg) + "/" + Util::toString(op) + ",S:" + 
			Util::toString(sl) + ">" );
	}

	if(u == getMe())
		state = STATE_NORMAL;

	fire(ClientListener::UserUpdated(), this, u);
}
Esempio n. 12
0
File: MD_EL.cpp Progetto: lcpt/xc
void XC::MDEvolutionLaw::UpdateAllVars( EPState *EPS, double dlamda) {
   
    //=========================================================================
    //calculate  n_ij
    XC::stresstensor S = EPS->getStress().deviator();
    double p = EPS->getStress().p_hydrostatic();
    XC::stresstensor alpha = EPS->getTensorVar( 1 );  // alpha_ij

    // Find the norm of alpha
    BJtensor norm_alphat = alpha("ij") * alpha("ij");
    double norm_alpha = sqrt( norm_alphat.trace() );
   
    XC::stresstensor r = S * (1.0 / p);
    //r.reportshort("r");
    XC::stresstensor r_bar = r - alpha;
    XC::stresstensor norm2 = r_bar("ij") * r_bar("ij");
    double norm = sqrt( norm2.trace() );
    
    XC::stresstensor n;
    if ( norm >= d_macheps() ){ 
      n = ( r  - alpha ) *(1.0 / norm );
    }
    else {
      ::printf(" \n\n n_ij not defined!!!! Program exits\n");
      exit(1);
    }
    //EPS->setTensorVar( 3, n); //update n_ij//

    // Update E_Young corresponding to current stress state
    double p_atm = 100.0; //Kpa, atmospheric pressure
    double E = EPS->getE();  // old E_Young
    double E_new = EPS->getEo() * pow( (p/p_atm), geta() ); 
    EPS->setE( E_new );

    // Update void ratio
    
    double e = EPS->getScalarVar(3);
    double D = EPS->getScalarVar(2);
    double elastic_strain_vol = EPS->getdElasticStrain().Iinvariant1();
    double plastic_strain_vol = EPS->getdPlasticStrain().Iinvariant1();

    double de_p = -( 1.0 + e ) * plastic_strain_vol; // plastic change of void ratio ?? e or eo?
    double de_e = -( 1.0 + e ) * elastic_strain_vol; // elastic change of void ratio ????
    clog << "get dPlasticStrain-vol" << plastic_strain_vol << std::endl;
    clog << "get dElasticStrain-vol" << elastic_strain_vol << std::endl;

    clog << "^^^^^^^^^^^ de_e = " << de_e << " de_p = " << de_p << std::endl; 
    double new_e = e + de_p + de_e;

    EPS->setScalarVar( 3, new_e ); // Updating e


    //Calculate the state parameters xi 
    double ec = getec_ref() - getLambda() * log( p/getp_ref() );

    double xi = e - ec;

    // Update D 
       
    double m = EPS->getScalarVar(1);
    XC::stresstensor F = EPS->getTensorVar( 2 );   // getting  F_ij from XC::EPState
    BJtensor temp_tensor = F("ij") * n("ij");
    double temp = temp_tensor.trace();
    if (temp < 0)   temp = 0;
    double A = Ao*(1.0 + temp);

    //Calculating the lode angle theta
    double J2_bar = r_bar.Jinvariant2();
    double J3_bar = r_bar.Jinvariant3();
    double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5);

    if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan
    if (tempd < -1.0 ) tempd = -1.0;

    double theta = acos( tempd ) / 3.0;
    
    //=========================================================================
    //calculate the alpha_theta_b and alpha_theta_d
    double c = getMe() / getMc();

    double cd = getke_d() / getkc_d();
    double alpha_theta_dd = (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m);
    XC::stresstensor alpha_theta_d = n("ij") * alpha_theta_dd * pow(2.0/3.0, 0.5);

    double cb = getke_b() / getkc_b();
    if ( xi > 0 ) xi = 0.0;  // < -xi >
    double alpha_theta_bd = (g_WW(theta, c) * Mc + g_WW(theta, cb) * kc_b * (-xi) - m);
    XC::stresstensor alpha_theta_b = n("ij") *alpha_theta_bd * pow(2.0/3.0, 0.5);
    alpha_theta_b.null_indices();

    XC::stresstensor b;
    b =  alpha_theta_b - alpha;
    b.null_indices();
    XC::stresstensor d;
    d =  alpha_theta_d - alpha;
    d.null_indices();

    BJtensor temp1 = d("ij") * n("ij");
    temp1.null_indices();
    double D_new = temp1.trace() * A;
    //Check the restrictions on D
    if ( (xi > 0.0) && ( D_new < 0.0) )
       D_new = 0.0;  

    EPS->setScalarVar(2, D_new);  // Updating D
    //EPS->setScalarVar(2, 0.0);  // Updating D
    
 
    //=========================================================================
    // Update m
    double dm = dlamda * getCm() * ( 1.0 + e ) * D;
    EPS->setScalarVar(1, m + dm); // Updating m
    clog  << std::endl << "dm = " << dm << std::endl;

    //=========================================================================
    // Update alpha

    //calculate b_ref
    double alpha_c_b = g_WW(0.0, c) * Mc + g_WW(0.0, cb) * kc_b * (-xi) - m;
    double b_ref = 2.0 * pow(2.0/3.0, 0.5) * alpha_c_b;
    
    temp1 = b("ij") * n("ij");
    double bn = temp1.trace();
    clog << "xxxxxxxxxxxxxxxxxxx  bn " << bn << std::endl;


    double h = getho() * fabs(bn) / ( b_ref - fabs(bn) );
    //h = h + pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * bn;

    clog << " ||b|| " << (alpha_theta_bd - norm_alpha) << std::endl;
    clog << " dlamda " << dlamda << " h = " << h << std::endl;

    XC::stresstensor dalpha;
    dalpha = dlamda * h * b("ij");
    //dalpha.null_indices();
    clog << "delta alpha =" << dalpha << std::endl;
    
    //dalpha.reportshortpqtheta("\n dalpha ");
    alpha = alpha + dalpha;
    alpha.null_indices();
    //alpha.reportshort("Alpha");
    EPS->setTensorVar(1, alpha);

    //=========================================================================
    // Update F
    XC::stresstensor dF;
    if ( D > 0.0 ) D = 0.0;
    dF =  dlamda * getCf() * (-D) * ( getFmax() * n("ij") + F("ij") );
    //clog << "dF" << dF;
    
    F = F - dF;
    EPS->setTensorVar(2, F);

}
Esempio n. 13
0
File: MD_EL.cpp Progetto: lcpt/xc
double XC::MDEvolutionLaw::getKp( EPState *EPS , double dummy) {

    //clog << "el-pl EPS: " <<  *EPS ;
    
    //=========================================================================
    //calculate  n_ij
    XC::stresstensor S = EPS->getStress().deviator();
    double p = EPS->getStress().p_hydrostatic();
    XC::stresstensor alpha = EPS->getTensorVar( 1 );  // alpha_ij
   
    XC::stresstensor r = S * (1.0 / p);
    //r.reportshort("r");
    XC::stresstensor r_bar = r - alpha;
    XC::stresstensor norm2 = r_bar("ij") * r_bar("ij");
    double norm = sqrt( norm2.trace() );
    
    XC::stresstensor n;
    if ( norm >= d_macheps() ){ 
      n = ( r  - alpha ) *(1.0 / norm );
    }
    else {
      ::printf(" \n\n n_ij not defined!!!! Program exits\n");
      exit(1);
    }
    
    //=========================================================================
    //calculating b_ij

    //Calculate the state parameters xi 
    double e = EPS->getScalarVar(3);
    double ec = getec_ref() - getLambda() * log( p/getp_ref() );
    double xi = e - ec;

    //Calculating the lode angle theta
    double J2_bar = r_bar.Jinvariant2();
    double J3_bar = r_bar.Jinvariant3();

    double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5);
    if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan
    if (tempd < -1.0 ) tempd = -1.0;
    double theta = acos( tempd ) / 3.0;

    
    //calculate the alpha_theta_b and alpha_theta_d
    double m = EPS->getScalarVar(1);
    double c = getMe() / getMc();

    double cd = getke_d() / getkc_d();
    XC::stresstensor alpha_theta_d = n("ij") * (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m) * pow(2.0/3.0, 0.5);


    double cb = getke_b() / getkc_b();
    if ( xi > 0.0 ) xi = 0.0;  // < -xi >
    XC::stresstensor alpha_theta_b = n("ij") * (g_WW(theta, c) * Mc - g_WW(theta, cb) * kc_b * xi - m) * pow(2.0/3.0, 0.5);
    alpha_theta_b.null_indices();

    //=========================================================================
    // calculating h
    XC::stresstensor b;
    b =  alpha_theta_b - alpha;
    b.null_indices();
    XC::stresstensor d;
    d =  alpha_theta_d - alpha;
    d.null_indices();

    double alpha_c_b = g_WW(0.0, c) * Mc + g_WW(0.0, cb) * kc_b * (-xi) - m;
    double b_ref = 2.0 * pow(2.0/3.0, 0.5) * alpha_c_b;
    

    BJtensor temp1 = b("ij") * n("ij");
    double bn = temp1.trace();

    temp1 = d("ij") * n("ij");
    double dn = temp1.trace();


    // Calculating A
    XC::stresstensor F = EPS->getTensorVar( 2 );   // getting  F_ij from XC::EPState
    temp1 = F("ij") * n("ij");
    double temp = temp1.trace();
    if (temp < 0)   temp = 0;
    double A = Ao*(1.0 + temp);

    double h = getho() * fabs(bn) / ( b_ref - fabs(bn) ); 
    clog << "ho =" << getho()  << "   h =" << h << std::endl;


    //=========================================================================

    double Kp = h * bn + pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * dn;
    //double Kp = pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * dn;
    Kp = Kp * p;

    return Kp;

}
Esempio n. 14
0
void AdcHub::hubMessage(const string& aMessage) {
	if(state != STATE_NORMAL)
		return;
	string strtmp;
	send("BMSG " + getMe()->getCID().toBase32() + " " + Command::escape(aMessage) + "\n"); 
}
Esempio n. 15
0
File: MD_EL.cpp Progetto: lcpt/xc
void XC::MDEvolutionLaw::setInitD(EPState  *EPS) {

    //=========================================================================
    //calculate  n_ij
    XC::stresstensor S = EPS->getStress().deviator();
    double p = EPS->getStress().p_hydrostatic();
    XC::stresstensor alpha = EPS->getTensorVar( 1 );  // alpha_ij

    // Find the norm of alpha
    BJtensor norm_alphat = alpha("ij") * alpha("ij");
    double norm_alpha = sqrt( norm_alphat.trace() );
   
    XC::stresstensor r = S * (1.0 / p);
    //r.reportshort("r");
    XC::stresstensor r_bar = r - alpha;
    XC::stresstensor norm2 = r_bar("ij") * r_bar("ij");
    double norm = sqrt( norm2.trace() );
    
    XC::stresstensor n;
    if ( norm >= d_macheps() ){ 
      n = ( r  - alpha ) *(1.0 / norm );
    }
    else {
      ::printf(" \n\n n_ij not defined!!!! Program exits\n");
      exit(1);
    }

    //Calculate the state parameters xi 
    double e = EPS->getScalarVar(3);
    double ec = getec_ref() - getLambda() * log( p/getp_ref() );
    double xi = e - ec;

    //calculating A
    double m = EPS->getScalarVar(1);
    XC::stresstensor F = EPS->getTensorVar( 2 );   // getting  F_ij from XC::EPState
    BJtensor temp_tensor = F("ij") * n("ij");
    double temp = temp_tensor.trace();
    if (temp < 0)   temp = 0;
    double A = Ao*(1.0 + temp);

    //Calculating the lode angle theta
    double J2_bar = r_bar.Jinvariant2();
    double J3_bar = r_bar.Jinvariant3();
    double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5);

    if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan
    if (tempd < -1.0 ) tempd = -1.0;

    double theta = acos( tempd ) / 3.0;
    
    //=========================================================================
    //calculate the alpha_theta_b and alpha_theta_d
    double c = getMe() / getMc();

    double cd = getke_d() / getkc_d();
    double alpha_theta_dd = (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m);
    XC::stresstensor alpha_theta_d = n("ij") * alpha_theta_dd * pow(2.0/3.0, 0.5);

    XC::stresstensor d;
    d =  alpha_theta_d - alpha;
    d.null_indices();

    BJtensor temp1 = d("ij") * n("ij");
    temp1.null_indices();
    double D_new = temp1.trace() * A;
    //Check the restrictions on D
    if ( (xi > 0.0) && ( D_new < 0.0) )
       D_new = 0.0;  

    EPS->setScalarVar(2, D_new);  // Updating D
    
}   
Esempio n. 16
0
void ClientManager::send(AdcCommand& cmd, const CID& cid) {
	Lock l(cs);
	OnlineIter i = onlineUsers.find(cid);
	if(i != onlineUsers.end()) {
		OnlineUser& u = *i->second;
		if(cmd.getType() == AdcCommand::TYPE_UDP && !u.getIdentity().isUdpActive()) {
			cmd.setType(AdcCommand::TYPE_DIRECT);
			cmd.setTo(u.getIdentity().getSID());
			u.getClient().send(cmd);
		} else {
			try {
				udp.writeTo(u.getIdentity().getIp(), static_cast<uint16_t>(Util::toInt(u.getIdentity().getUdpPort())), cmd.toString(getMe()->getCID()));
			} catch(const SocketException&) {
				dcdebug("Socket exception sending ADC UDP command\n");
			}
		}
	}
}
Esempio n. 17
0
void ClientManager::on(Load, SimpleXML&) throw() {
	users.insert(make_pair(getMe()->getCID(), getMe()));
}
Esempio n. 18
0
unsigned TableManager::tableHashCode(const void* anyArg)
{
    return ((*(unsigned int *)anyArg) % getMe().tableCount);
}
Esempio n. 19
0
unsigned TableManager::get_dummy_hash(const void* anyArg)
{
    return (((*(unsigned int *)anyArg)/getMe().tableSize)-1) % 256;
}
Esempio n. 20
0
unsigned int TableManager::myDBHashCode(const void* anyArg)
{
    return (*((unsigned int *)anyArg))% getMe().dbCount;
}
Esempio n. 21
0
unsigned int TableManager::dbHashCode(const void* anyArg)
{
    return (((*((unsigned int *)anyArg))%getMe().tableCount) /getMe().tablePerDB);
}
Esempio n. 22
0
void AdcHub::privateMessage(const User* user, const string& aMessage) { 
	if(state != STATE_NORMAL)
		return;
	string strtmp;
	send("DMSG " + user->getCID().toBase32() + " " + getMe()->getCID().toBase32() + " " + Command::escape(aMessage) + " PM\n"); 
}
Esempio n. 23
0
void AdcHub::ban(const User* user, const string& aMessage, time_t aSeconds) { 
	if(state != STATE_NORMAL)
		return;
	string strtmp;
	send("HDSC " + user->getCID().toBase32() + " BA BA " + getMe()->getCID().toBase32() + " " + Util::toString((u_int32_t)aSeconds) + " " + Command::escape(aMessage) + "\n"); 
}
Esempio n. 24
0
void AdcHub::redirect(const User* user, const string& aHub, const string& aMessage) { 
	if(state != STATE_NORMAL)
		return;
	string strtmp;
	send("HDSC " + user->getCID().toBase32() + " RD RD " + getMe()->getCID().toBase32() + " " + aHub + " " + Command::escape(aMessage) + "\n"); 
}