/** * Pobiera następny pakiet do wysłania. */ RTPPacket& StegLACK::getNextPacket() { vector<char> payloadData; //we are doing the sequence if ( ! stegTransferDone && intervalCount >= seqFireInterval) { StegSeqElem se = stegSeq[seqPosition]; long delay = getRandNumber(se.intervMin, se.intervMax); templatePacket.delay = delay; //wysylamy steg packet if (se.isStegPacket && ! stegTransferDone) { payloadData = getStegDataToSend(); PRN_(1, "in steg sequence: sending packet: steg"); VAR_(1, delay); } //wysylamy audio packet else { //dodajemy audio do pakietu: payloadData = getAudioDataToSend(); PRN_(1, "in steg sequence: sending packet: audio"); VAR_(1, delay); } seqPosition++; //we finished the sequence... if ((unsigned) seqPosition == stegSeq.size()) { seqPosition = intervalCount = 0; seqFireInterval = getRandNumber(config->minStegInterval, config->maxStegInterval); } } //we send the normal package else { intervalCount++; templatePacket.delay = config->noStegRTPDelay; PRN_(1, "sending normal packet"); //dodajemy audio do pakietu: payloadData = getAudioDataToSend(); } templatePacket.payload = new char[payloadData.size()]; templatePacket.payloadSize = payloadData.size(); for (int i = 0; i < (int) payloadData.size(); i++) { templatePacket.payload[i] = payloadData[i]; } //return prepared packet return templatePacket; }
bool GameLayer::init() { if (!Layer::create()) { return false; } initMapAndHero(); initUI(); AnimationManager::getInstrans()->addAllAnimationCache(); //键盘事件注册 auto keyEventListen = EventListenerKeyboard::create(); keyEventListen->onKeyPressed = CC_CALLBACK_2(GameLayer::onKeyPressed, this); keyEventListen->onKeyReleased = CC_CALLBACK_2(GameLayer::onKeyReleased, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(keyEventListen, this); //this->setTouchEnabled(true); CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(0.5f); int index = getRandNumber(1,4); std::string str = StringUtils::format("r_bgm_0%d.wav",index); CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(str.c_str(), true); this->scheduleUpdate(); hero->setState(eRight); isRightKeyDown = true; return true; }
void GameLayer::initMapAndHero() { gameMap = GameMap::create("image/map/MyKuPaoMap1.tmx"); mapSize = CCSizeMake(gameMap->getMapSize().width*gameMap->getTileSize().width, gameMap->getMapSize().height*gameMap->getTileSize().height); gameMap->setPosition(Point(0, 0)); hero = Hero::create(); hero->setAnchorPoint(Point(0, 0)); hero->setPosition(gameMap->getHeroBirthPlace()); int index = getRandNumber(1,6); std::string str = StringUtils::format("Background_1%d.png",index); auto bgPic = Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance() ->getSpriteFrameByName(str)); bgPic->setAnchorPoint(Point::ZERO); bgPic->setPosition(Point(0, 20)); this->addChild(bgPic); mainLayer = Layer::create(); mainLayer->addChild(gameMap); mainLayer->addChild(hero); mainLayer->setPosition(Point(0, 0)); this->addChild(mainLayer); }
StegLACK::StegLACK(Config* cfg) : VoIPPacketsManager(cfg) { srand((unsigned) time(0)); string seq = cfg->stegSequence; bool done = false; while (!done) { int pos = seq.find_first_of(" "); if (pos == -1) done = true; stegSeq.push_back(StegSeqElem(seq.substr(0, pos))); seq = seq.substr(pos + 1); } timeSinceLastQueueRead.start(); intervalCount = 0; seqPosition = 0; lastReadStegByte = -1; seqFireInterval = getRandNumber(config->minStegInterval, config->maxStegInterval); stegTransferDone = false; readStegDataToMem(); VAR_(3, seqFireInterval); }
static int lfprng_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) { long long val = getRandNumber(current->tgid, current->pid, procID.seed); int length = sprintf(page, "%lld", val); return length; }//end lfprng_read_proc function
CAction::CAction( bool _autoDelete ) : m_inProgress( false ) , m_executed( false ) , m_autoDelete( _autoDelete ) , m_exit( false ) { m_actionKey = getRandNumber(); CNetworkActionRegister::getInstance()->registerServicedByAction( m_actionKey );// this shouldn't be here in reality };