示例#1
0
void BackupManagerI::put(const OccupantPtr& o, const Ice::Current&) {
	MCE_DEBUG("BackupManagerI::put");
	if (o && o->rJid && o->rJid->rid) {
		MCE_DEBUG("BackupManagerI::put --> rjid:"<< roomJidToString(o->rJid));
		Ice::Long hashcode = StrUtil::hashcode(roomIdToString(o->rJid->rid));
		RoomInfoPtr ri = ServiceI::instance().locateObject<RoomInfoPtr>(ROOM_INFO, hashcode);
		MCE_DEBUG("BackupManagerI::put --> hashcode:"<< hashcode << " ri.size:"<<ri->get(o->rJid->rid).size());
		if (ri) {
			ri->put(o);
		}
		_addUpdateSqlObj(o);
	}
}
示例#2
0
Ice::ObjectPtr RoomInfoFactoryI::create(Ice::Long hashcode) {
	Statement sql;
	sql << "select * from occupant_backup where hashcode = " << boost::lexical_cast<string>(hashcode).c_str();
	//MCE_DEBUG("RoomFactoryI::create --> " << sql);
	try {
#ifndef NEWARCH
		mysqlpp::Result res = QueryRunner("im_groupchat", CDbRServer).store(sql);
#else
		mysqlpp::StoreQueryResult res = QueryRunner("im_groupchat", CDbRServer).store(sql);
#endif
		MCE_DEBUG("RoomInfoFactoryI::create --> load occupant_backup from database, count=" << res.size());
		RoomInfoPtr ri = new RoomInfo();
		for (size_t i= 0; i<res.size(); ++i) {

			mysqlpp::Row row = res.at(i);

			OccupantPtr o = new Occupant();
#ifndef NEWARCH
			o->rJid = stringToRoomJid(row["rjid"].get_string());
#else
			o->rJid = stringToRoomJid(row["rjid"].c_str());
#endif
			o->fJid = new Jid();
			o->fJid->userId = (int)row["userid"];
#ifndef NEWARCH
			o->fJid->endpoint = row["endpoint"].get_string();
#else
			o->fJid->endpoint = row["endpoint"].c_str();
#endif
			o->fJid->index = (Ice::Long)row["jid_index"];

			o->aType = (Affiliation)(int)row["affiliation"];
			o->role = (RoomRole)(int)row["role"];

			ri->put(o);
		}
		return ri;
	} catch(Ice::Exception& e) {
		MCE_WARN(e << " at " << __FILE__ << ":" << __LINE__);
	} catch (std::exception& e) {
		MCE_WARN(e.what() << " at " << __FILE__ << ":" << __LINE__);
	} catch (...) {
		MCE_WARN("Unkown exception at " << __FILE__ << ":" << __LINE__);
	}

	return 0;
}