void PetDetailTrainLayer::onGoldCoinClick(cocos2d::Ref *sender) //------选择银币方式培养 { isSelectType = 1; //传给服务器是哪种方式支付 HaypiJsonPtr msg = HaypiJsonCPP::createJsonOnlyWithAction(3453); msg->at("PUID") = getUserID(); msg->at("UseType") = isSelectType; NetManager::send(msg, pl_Normal, [&](HaypiJsonPtr data) { if(data->at("ACTION_COM").asInt() == 3463) { MsgBox::show( data->at("ExtraInfo").asString()); return ; } else { auto foster = data->at("Foster"); hpSum = foster["HP"].asInt(); atkSum = foster["Ak"].asInt(); defSum = foster["Def"].asInt(); atcSum = foster["McAk"].asInt(); decSum = foster["McDef"].asInt(); speSum = foster["Speed"].asInt(); isTrain = true; isSaveSuccess = false; } this->resetUI(); }); }
bool CUserItem::getAsString( wxString& strUser ) { wxString wxstr; strUser.Empty(); strUser += wxString::Format( _("%ld;"), getUserID() ); strUser += getUser(); strUser += _(";"); // Protect password wxstr = getPassword(); for ( int i=0; i<wxstr.Length(); i++ ) { strUser += _("*"); } //strUser += getPassword(); strUser += _(";"); strUser += getFullname(); strUser += _(";"); vscp_writeFilterToString( getFilter(), wxstr ); strUser += wxstr; strUser += _(";"); vscp_writeMaskToString( getFilter(), wxstr ); strUser += wxstr; strUser += _(";"); strUser += getUserRightsAsString(); strUser += _(";"); strUser += getAllowedRemotesAsString(); strUser += _(";"); strUser += getAllowedEventsAsString(); strUser += _(";"); strUser += wxBase64Encode( getNote().mbc_str(), strlen( getNote().mbc_str() ) ); //strUser += getNote(); return true; }
void PetDetailInfoLayer::onlockClick(cocos2d::Ref *sender) //-----锁 { HaypiJsonPtr msg = HaypiJsonCPP::createJsonOnlyWithAction(3456); msg->at("PUID") = getUserID(); msg->at("IsLocked") = !_islock; NetManager::send(msg, pl_Normal, [&](HaypiJsonPtr data){ this->resetUI(); }); }
int main(int argc, char* argv[]) { long status; unsigned long cardType; unsigned long cardSN; BYTE userID; status = OpenPort(1, 9600); if (!status) { status = LinkRW(); if (status) { ClosePort(); fprintf(stderr, "Connect Fail\n"); return -1; } fprintf(stderr, "Connect Succeed\n"); //beepOn(); //card polling while (1) { status = GetCardType(&cardType); if (!status) { delayMS(5); if (cardType == 4) { //Mifare 1 status = mfGetCardSnr(&cardSN); if (status) { status = mfTransKey(); if (status) { status = SelectCard(cardSN); if (!status) { fprintf(stderr, "Activate Succeed\n"); userID = getUserID(cardSN); fprintf(stdout, "%x", userID); HaltCard(); //delayMS(3000); break; } } } } } } } else { fprintf(stderr, "Connect Fail\n"); return -1; } ClosePort(); return 0; }
FhgfsOpsErr LookupIntentMsgEx::create(EntryInfo* parentInfo, std::string& entryName, EntryInfo *outEntryInfo, FileInodeStoreData* outInodeData) { const int umask = isMsgHeaderFeatureFlagSet(LOOKUPINTENTMSG_FLAG_UMASK) ? getUmask() : 0000; MkFileDetails mkDetails(entryName, getUserID(), getGroupID(), getMode(), umask ); UInt16List preferredTargets; parsePreferredTargets(&preferredTargets); return MsgHelperMkFile::mkFile(parentInfo, &mkDetails, &preferredTargets, 0, 0, outEntryInfo, outInodeData); }
int AGIPRoleList::showInfo() { int nRetCode = E_ERROR; uint32_t unUserID = 0; SysProtocol::showInfo(); nRetCode = getUserID(&unUserID); printf("--------------------------------------------------------AGIPRoleList\n"); printf("User_ID:\t%u\n", unUserID); printf("--------------------------------------------------------AGIPRoleList\n"); return S_SUCCESS; }
void service::createVolumes(const drunnerCompose * const drc) { if (drc == NULL) logmsg(kLERROR, "createVolumes passed NULL drunnerCompose."); std::string dname = "docker-volume-maker"; for (const auto & svc : drc->getServicesInfo()) { // each service may be running under a different userid. std::string userid = getUserID(svc.mImageName); if (userid == "0") logmsg(kLERROR, svc.mImageName + " is running as root user! Verboten."); // should never happen as we've validated the image already. for (const auto & entry : svc.mVolumes) { if (utils::dockerVolExists(entry.mDockerVolumeName)) logmsg(kLINFO, "A docker volume already exists for " + entry.mDockerVolumeName + ", reusing it for " + svc.mImageName + "."); else { std::string op; int rval = utils::bashcommand("docker volume create --name=\"" + entry.mDockerVolumeName + "\"", op); if (rval != 0) logmsg(kLERROR, "Unable to create docker volume " + entry.mDockerVolumeName); logmsg(kLDEBUG, "Created docker volume " + entry.mDockerVolumeName + " for " + svc.mImageName); } // set permissions on volume. tVecStr args; args.push_back("docker"); args.push_back("run"); args.push_back("--name=\"" + dname + "\""); args.push_back("-v"); args.push_back(entry.mDockerVolumeName + ":" + "/tempmount"); args.push_back("drunner/rootutils"); args.push_back("chown"); args.push_back(userid + ":root"); args.push_back("/tempmount"); utils::dockerrun dr("/usr/bin/docker", args, dname, mParams); logmsg(kLDEBUG, "Set permissions to allow user " + userid + " access to volume " + entry.mDockerVolumeName); } } }
void Player::handleRequest(unsigned char* buf, int len){ short header = buf[0] + buf[1]*0x100; try{ switch(header){ case 0x14: getUserID(buf+2); break; case 0x21: NPCs::handleNPCIn(this ,buf+2); break; case 0x22: Inventory::useShop(this ,buf+2); break; case 0x23: NPCs::handleNPC(this, buf+2); break; case 0x27: MasterServer::changeChannel(this, buf+2); break; case 0x2A: Players::damagePlayer(this ,buf+2); break; case 0x2B: Inventory::stopChair(this ,buf+2); break; case 0x2C: Players::chatHandler(this ,buf+2); break; case 0x2D: Inventory::useChair(this ,buf+2); break; case 0x2E: Mobs::damageMobSkill(this ,buf+2); break; case 0x2F: Maps::moveMap(this ,buf+2); break; case 0x35: Players::handleMoving(this ,buf+2, len-2); break; case 0x36: Mobs::damageMobS(this ,buf+2, len-2); break; case 0x44: Players::getPlayerInfo(this, buf+2); break; case 0x4B: Inventory::useSummonBag(this, buf+2); break; case 0x4D: Skills::addSkill(this, buf+2); break; case 0x4E: Skills::cancelSkill(this, buf+2); break; case 0x51: Skills::useSkill(this, buf+2); break; case 0x58: Players::searchPlayer(this ,buf+2); break; case 0x59: Mobs::damageMob(this ,buf+2); break; case 0x5C: Players::faceExperiment(this ,buf+2); break; case 0x5D: Inventory::useItemEffect(this, buf+2); break; case 0x62: Inventory::itemMove(this ,buf+2); break; case 0x63: Inventory::useItem(this, buf+2); break; case 0x64: Inventory::useReturnScroll(this, buf+2); break; case 0x65: Inventory::useScroll(this, buf+2); break; case 0x66: Levels::addStat(this, buf+2); break; case 0x67: Players::healPlayer(this, buf+2); break; case 0x68: Drops::dropMesos(this ,buf+2); break; case 0x6B: Quests::getQuest(this, buf+2); break; case 0x75: chaneKey(buf+2); case 0x89: Drops::lootItem(this ,buf+2); break; case 0x9D: Mobs::monsterControl(this ,buf+2, len-2); break; case 0xA0: Mobs::monsterControlSkill(this ,buf+2); break; } } catch(...){ printf("Error with the header: %x\n", header); } }
int AGIPUserLoginRes::showInfo() { int nRetCode = E_ERROR; int32_t nResultCode = 0; uint32_t unUserID = 0; int8_t cUserType = 0; int8_t cAdultFlag = 0; int8_t cUserClass = 0; int8_t cUserRoleCount = 0; int32_t nUserPoint = 0; uint32_t unPromoterID = 0; uint32_t unUserFlag = 0; SysProtocol::showInfo(); nRetCode = getResultCode(&nResultCode); nRetCode = getUserID(&unUserID); nRetCode = getUserType(&cUserType); nRetCode = getAdultFlag(&cAdultFlag); nRetCode = getUserClass(&cUserClass); nRetCode = getUserRoleCount(&cUserRoleCount); nRetCode = getUserPoint(&nUserPoint); nRetCode = getPromoterID(&unPromoterID); nRetCode = getUserFlag(&unUserFlag); printf("--------------------------------------------------------AGIPUserLoginRes\n"); printf("Result_Code:\t%d\n", nResultCode); printf("User_ID:\t%u\n", unUserID); printf("User_Type:\t%d\n", cUserType); printf("Adult_Flag:\t%d\n", cAdultFlag); printf("User_Class:\t%d\n", cUserClass); printf("User_Role_Count:\t%d\n", cUserRoleCount); printf("User_Point:\t%d\n", nUserPoint); printf("Promoter_ID:\t%u\n", unPromoterID); printf("User_Flag:\t%u\n", unUserFlag); printf("--------------------------------------------------------AGIPUserLoginRes\n"); return S_SUCCESS; }
void PetDetailInfoLayer::resetUI() { auto pet = getCurrBag()->getPetByID(getUserID());//-----得到用户点击的宠物 _islock = pet->isLocked(); if (_islock) { _imglock->loadTexture("pet_look_b.png", Widget::TextureResType::PLIST); } else { _imglock->loadTexture("pet_look_a.png", Widget::TextureResType::PLIST); } auto stTimer = StrengthTimerManager::getInstance()->getTaskByPetID(pet->getUserId()); stTimer->onTimerUpdate(); //-----------------------------------宠物图表信息-------------------------------------// _icon->loadTexture(_X(pet->getBigFrontIcon(), _icon)); //------获取宠物的头像 UIHelper::setStars(_stars[0]->getParent(), pet->getStarNum(), pet->getStarMax()); _evaluate->loadTexture(pet->getUintIcon(), Widget::TextureResType::PLIST); //------品种(S, SS, A, 等待) //-----------------------------宠物数据信息--------------------------------------------// _petName->setString(StringUtils::format("Bahamu")); //----宠物名字 _attr->loadTexture(StringUtils::format("base_property%d.png", pet->getKeyPet()->attr), Widget::TextureResType::PLIST); //----宠物的属性(火、水.....) _lv->setString(StringUtils::format("%s.%d", "Lv", pet->getLevel())); //----等级显示 auto monster = MonsterExpConfig::getMonsterExpBy(pet->getLevel()); _lv_Text->setString(StringUtils::format("%d/%d", pet->getExp(), monster->expLvup)); //升级经验数值 _lv_LoadingBar->setPercent(pet->getExp() * 100.0 / monster->expLvup); //经验条 _hp_Text->setString(StringUtils::format("%d/%d", pet->getHP(), pet->getHpMax())); //hp数值 _hp_LoadingBar->setPercent(pet->getHP() * 100.0 / pet->getHpMax()); _energy_Text->setString(_T("%d/100", pet->getStrength())); //------能量值 _energy_Text->runAction(UserPetTimer::create(_uid)); _energy_LoadingBar->setPercent(pet->getStrength()); //------能量条显示为0 _energy_LoadingBar->runAction(UserPetTimer::create(_uid)); _hp_Value->setString(StringUtils::format("%d", pet->getBaseHp())); //-------血量 _hp_add->setString(StringUtils::format("+%d", pet->getAddedHp())); //-------额外增加的 _atk_Value->setString(StringUtils::format("%d", pet->getBaseAttack())); //-------攻击 _atk_add->setString(StringUtils::format("+%d", pet->getAddedAttack())); //-------额外增加的 _def_Value->setString(StringUtils::format("%d", pet->getBaseDefense())); //-------防御力 _def_add->setString(StringUtils::format("+%d", pet->getAddedDefense())); _atc_Value->setString(StringUtils::format("%d", pet->getBaseMAttack())); //------魔攻 _atc_add->setString(StringUtils::format("+%d", pet->getAddedMAttack())); _dec_Value->setString(StringUtils::format("%d", pet->getBaseMDefense())); //------魔防 _dec_add->setString(StringUtils::format("+%d", pet->getAddedMDefense())); _spe_Value->setString(StringUtils::format("%d", pet->getBaseSpeed())); //------速度 _spe_add->setString(StringUtils::format("+%d", pet->getAddedSpeed())); }
/*-----------------------------------------------------------------------------*/ int main(int argc, char **argv) { char str[MAX_STR]; char userID[MAX_USER_NAME]; char buffer[MAX_BUFF]; SongType tempSong; /* Ncurses Menu */ char *mContent[] = { "Add Song", "Delete Song", "View Song(s)", "Quit" }; // dealWithIt(); printLogo("CLIENT", CLEAR); /* External Preprocessor commands */ if (extArguments (argc,argv) == 0) {return 0;} /* Welcome Screen and ask for username */ getUserID(userID, (unsigned) sizeof(userID)); /* Initiats connections */ initClientSocket(); /* Display confirmation for user */ printf(ANSI_COLOR_GREEN "Establising connection to server %s:%d \n\n" "For further assistance or " "help, please visit the help page by simply typing " ANSI_COLOR_YELLOW "'/h'" ANSI_COLOR_RESET" \n", SERVER_IP, SERVER_PORT); /* SEND USER THAT WE GOT FROM THE ABOVE fgets */ userID[strlen(userID)-1] = '\0'; // add a terminator at the end of the char[] strcpy(buffer, userID); send(mySocket, buffer, strlen(buffer), 0); /* Display Menu - Keep this if not using dup / dup2*/ dispMenu(); while (1) { /* For eye candy */ // printLogo("CLIENT", NO_CLEAR); /* Display Menu first */ // dispMenu(); // initNcursesMenu((sizeof(mContent) / sizeof(char*)),*mContent); printf("Please choose from the menu above: "); fgets(str, sizeof(str), stdin); str[strlen(str)-1] = '\0'; /* Deprecated * if (strcmp(str, "/h") == 0) { * printf(ANSI_COLOR_CYAN * "Welcome to the help page. This is a beta-help page\n" * "With later releases the help page should be using\n" * "the ncurses library.\n" * "Commands include :\n" * ANSI_COLOR_RED * "\t/h\t: For this lovely page\n" * "\t/q\t: Closes this program.\n" * ANSI_COLOR_RESET * ); * } else */ strcpy(buffer, str); /*Encryption - Usually one would use a key, but not in this case.*/ // encrypt(buffer); // send(mySocket, buffer, strlen(buffer), 0); encryptSend(mySocket, buffer, strlen(buffer),0); if (strcmp(str, "/q") == 0) { /* Soft-quiting */ break; } else if (strcmp(str, "a") == 0) { /* Add Song */ printf("You are about to send a song over: Please enter the following: \n" ANSI_COLOR_YELLOW "Name : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Artist: "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Album : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Duration (mins) : "); /* Just to make sure the user will use integars, if it is not the case * then he/she will be promted again to repeat their input. */ for(;;){ short *illegals = 0; fgets(str, sizeof(str), stdin); /* Check if str contains any non-ints*/ for (int i = 0; i < strlen(str) - 1; ++i) { if(!isdigit(str[i])) ++illegals; } /* If everything seems to be good, then exit*/ if ( illegals == 0) { tempSong.duration = atoi(str); // fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); /* Free illegals ... */ free(illegals); break; } printf(ANSI_COLOR_RED "EYYY!!! YO CHILL MAN!!" ANSI_COLOR_RESET " Only Integar values!\nLet's try that again...\n" ANSI_COLOR_YELLOW "Duration (mins) : " ); } // end sentinital loop ( I don't know how to spell, don't judge sheesh ) printf(ANSI_COLOR_GREEN "We are all good. Converting your song to send over\n" ANSI_COLOR_RESET ); } else if (strcmp(str, "b") == 0) { /* Delete Song */ printf(ANSI_COLOR_YELLOW); printf("Which song do you want to delete?\n" "Name ? : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("Artist : "); fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); printf("That should be enough info\n"); printf(ANSI_COLOR_RESET); } else if (strcmp(str, "c") == 0) { /* View Song(s) */ fgets(str, sizeof(str), stdin); str[strlen(str) - 1] = '\0'; encryptSend(mySocket, str, strlen(str),0); } else if (strcmp(str, "d") == 0) { break; } } close(mySocket); return 0; }
/* ******************************************************************* * Function: * * Description: * * Parameters: * * Returns: * ******************************************************************* */ void xDistributedSession::removeUser(xDistributedClient *client) { xNetInterface *nInterface = getNetInterface(); if (!nInterface) { return; } xDistributedClient *myClient = nInterface->getMyClient(); if (client && myClient && client->getUserID() == myClient->getUserID()) { myClient->setSessionID(-1); } if (client) { if (isClientJoined(client->getUserID())) { ////////////////////////////////////////////////////////////////////////// if (client->getUserID() == getUserID()) { xLogger::xLog(XL_START,ELOGINFO,E_LI_SESSION,"Session master %d left session %d",client->getUserID(),getSessionID()); if (nInterface) { ////////////////////////////////////////////////////////////////////////// //we tag all existing users as new : IDistributedObjects *doInterface = nInterface->getDistObjectInterface(); xDistributedObjectsArrayType *distObjects = nInterface->getDistributedObjects(); xDistObjectIt begin = distObjects->begin(); xDistObjectIt end = distObjects->end(); while (begin!=end) { xDistributedObject *distObject = *begin; if (distObject) { xDistributedClass *_class = distObject->getDistributedClass(); if (_class) { if (_class->getEnitityType() == E_DC_BTYPE_CLIENT ) { xDistributedClient *distClient = static_cast<xDistributedClient*>(distObject); if (distClient && isClientJoined(distClient->getUserID())) { if (isFlagOn(distClient->getClientFlags(),E_CF_SESSION_JOINED)) { //distClient->setSessionID(-1); disableFlag(distClient->getClientFlags(),E_CF_SESSION_JOINED); enableFlag(distClient->getClientFlags(),E_CF_DELETING); enableFlag(distClient->getClientFlags(),E_CF_SESSION_DESTROYED); xLogger::xLogExtro(0,"\tRemoving user %d from session",distClient->getUserID(),getSessionID()); } } } } } begin++; } getClientTable().clear(); goto ENDUPDATE; return; } } } if (client->getUserID() != getUserID()) { enableFlag(client->getClientFlags(),E_CF_REMOVED); client->setSessionID(-1); } ////////////////////////////////////////////////////////////////////////// for(int i = 0 ; i < getClientTable().size() ; i++) { std::vector<xDistributedClient*>::iterator begin = getClientTable().begin(); std::vector<xDistributedClient*>::iterator end = getClientTable().end(); while (begin !=end) { xDistributedClient *current = *begin; if (current && current->getUserID() == client->getUserID() ) { getClientTable().erase(begin); } begin++; } } goto ENDUPDATE; ENDUPDATE : xDistributedInteger *numUser= (xDistributedInteger *)getProperty(E_DC_S_NP_NUM_USERS); numUser->updateValue(getClientTable().size(),0); setNumUsers(getClientTable().size()); int blockIndex = numUser->getBlockIndex(); getUpdateBits().set(1<<blockIndex,true); setMaskBits(1<<blockIndex); }else xLogger::xLog(XL_START,ELOGERROR,E_LI_SESSION,"couldn't find client object"); }
/* ******************************************************************* * Function: * * Description: * * Parameters: * * Returns: * ******************************************************************* */ void xDistributedSession::unpackUpdate(TNL::GhostConnection *connection, TNL::BitStream *stream) { xNetInterface *netInterface = (xNetInterface*) connection->getInterface(); if (netInterface) { ////////////////////////////////////////////////////////////////////////// //initial update ? if(stream->readFlag()) { if(stream->readFlag()) { char oName[256];stream->readString(oName); // retrieve objects name : char cName[256];stream->readString(cName); // retrieve objects dist class name : int type = stream->readInt(32); //read the dist class base type : int userID = stream->readInt(32); int serverID2 = stream->readInt(32); float creationTime = 0.0f; stream->read(&creationTime); int sessionID = stream->readInt(32); int MaxUsers = stream->readInt(32); char pass[256];stream->readString(pass); ////////////////////////////////////////////////////////////////////////// //now we store all in the dist object : //find and store the dist class : xDistributedClassesArrayType *_classes = netInterface->getDistributedClassInterface()->getDistrutedClassesPtr(); xDistributedClass *classTemplate = netInterface->getDistributedClassInterface()->get(cName,type); if (!classTemplate) { xLogger::xLog(ELOGERROR,E_LI_SESSION,"Warning initial unpack of session %s failed : no related class found : %s",oName,cName); //xLogger::xLog(ELOGINFO,XL_START,"Warning Initial Unpack Update, no related class found : %s",cName); //xLogger::xLog(ELOGERROR,XL_SESSION,"Warning Initial Unpack Update, no related class found : %s",cName); classTemplate = netInterface->getDistributedClassInterface()->createClass(cName,type); } setDistributedClass(classTemplate); SetName(oName); setServerID(connection->getGhostIndex(this)); setObjectFlags(E_DO_CREATION_CREATED); setUserID(userID); setNetInterface(netInterface); setCreationTime(creationTime); setSessionID(sessionID); getOwnershipState().set( 1<<E_DO_OS_OWNER, getUserID() == ((vtConnection*)connection)->getUserID() ); setInterfaceFlags(E_DO_CREATED); getSessionFlags().set( 1 << E_SF_INCOMPLETE ); xLogger::xLog(ELOGTRACE,E_LI_SESSION,"Retrieved initial state of session %s",oName); initProperties(); setMaxUsers(MaxUsers); setPassword(xNString(pass)); vtConnection *con = (vtConnection*)connection; setOwnerConnection(con); } } int updateBits = stream->readSignedInt(32); TNL::BitSet32 updateBitsMask(updateBits); setGhostUpdateBits(updateBits); xDistributedPropertyArrayType &props = *getDistributedPorperties(); int propCounter = 0; for (unsigned int i = 0 ; i < props.size() ; i++ ) { xDistributedProperty *prop = props[i]; xDistributedPropertyInfo*propInfo = prop->getPropertyInfo(); int blockIndex = prop->getBlockIndex(); if (updateBitsMask.testStrict(1<<blockIndex)) { prop->updateFromServer(stream); xLogger::xLog(ELOGTRACE,E_LI_SESSION,"Client : retrieving session property : %s |pred :%d",prop->getPropertyInfo()->mName.getString(),prop->getPropertyInfo()->mPredictionType); //xLogger::xLog(ELOGINFO,XL_START,"client : retrieving session property : %s",prop->getPropertyInfo()->mName.getString()); getSessionFlags().set( 1 << E_SF_COMPLETE ); propCounter++; } } if (propCounter == props.size()) { getSessionFlags().set( 1 << E_SF_COMPLETE ); } } }
/* ******************************************************************* * Function: * * Description: * * Parameters: * * Returns: * ******************************************************************* */ TNL::U32 xDistributedSession::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream) { xNetInterface *netInterface = (xNetInterface*) connection->getInterface(); if (netInterface) { //the first time ? : we write out all necessary attributes for the client : if(stream->writeFlag(updateMask & InitialMask)) { if(stream->writeFlag(true)) { //write out name : stream->writeString(GetName().getString(),strlen(GetName().getString())); //retrieve its class : xDistributedClass *distClass = getDistributedClass(); if (distClass) { //write out the class name : stream->writeString(distClass->getClassName().getString(),strlen(distClass->getClassName().getString())); //write out the class base type : stream->writeInt(distClass->getEnitityType(),32); //write out users id : vtConnection *con = (vtConnection*)connection; int uid = getUserID(); stream->writeInt(getUserID(),32); //write out server side id : int serverID = connection->getGhostIndex(this); stream->writeInt(connection->getGhostIndex(this),32); setServerID(connection->getGhostIndex(this)); float time = getCreationTime(); //write out creation time stream->write(getCreationTime()); // xLogger::xLog(ELOGINFO,XL_START,"server:init pack update of %s: %f , %d , ",GetName().getString(),time,uid); stream->writeInt(getSessionID(),32); stream->writeInt(getMaxUsers(),32); stream->writeString(getPassword().getString(),strlen(getPassword().getString())); //netInterface->deploySessionClasses(connection); } setNetInterface(netInterface); } } /************************************************************************/ /* */ /************************************************************************/ stream->writeSignedInt(getUpdateBits().getMask(),32); //xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d", getUpdateBits().getMask() ); xDistributedPropertyArrayType &props = *getDistributedPorperties(); for (unsigned int i = 0 ; i < props.size() ; i++ ) { xDistributedProperty *prop = props[i]; xDistributedPropertyInfo*propInfo = prop->getPropertyInfo(); int blockIndex = prop->getBlockIndex(); if (propInfo) { if (getUpdateBits().testStrict(1<<blockIndex)) { prop->updateGhostValue(stream); //xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d",blockIndex); } } } //getUpdateBits().clear(); } return 0; }
void PacketAnalyzer::run() { // read packet char errbuf[PCAP_ERRBUF_SIZE]; vector<string>::iterator it; pcap_t *trace_file; string curr_folder, tmp_folder, tmp_s; int trace_count = 0; for (it = mTraceList.begin(); it != mTraceList.end(); it++) { if (trace_count % 1000 == 0) { cout << trace_count << " files processed." << endl; } // open pcap file successfully? if ((trace_file = pcap_open_offline(it->c_str(), errbuf)) == NULL) { cout << " Unable to open the file: " << *it << endl; continue; } // read application map, screen status and process stat tmp_folder = getFolder(*it); tmp_folder += "appname"; if (tmp_folder.compare(curr_folder) != 0) { curr_folder = tmp_folder; cout << "Folder Name: " << curr_folder << endl; mTraceCtx.clearAppNameMap(); ifstream appNameFile(tmp_folder.c_str()); while (getline(appNameFile, tmp_s)) { mTraceCtx.addAppName(tmp_s); } mTraceCtx.updateFile(getFolder(*it)); } // get user ID mTraceCtx.setUserID(getUserID(*it)); // pcap link layer header length if (pcap_datalink(trace_file) == DLT_LINUX_SLL) { mTraceCtx.setEtherLen(16); } else { mTraceCtx.setEtherLen(14); } //cout << "Pcap trace Ethernet header length: " << mTraceCtx.getEtherLen() << endl; /* read and dispatch packets until EOF is reached */ pcap_loop(trace_file, 0, dispatcher_handler, (u_char *) this); pcap_close(trace_file); trace_count++; } // end vector<int*>::iterator end_it; for (end_it = mTrafficAbstract.begin(); end_it != mTrafficAbstract.end(); end_it++) { ((TrafficAbstract*)(*end_it))->runCleanUp(); } }