bool ProtocolSpectator::parseCoomand(std::string text) { if (text[0] == '/') { StringVec t = explodeString(text.substr(1, text.length()), " ", 1); if (t.size() > 0) { toLowerCaseString(t[0]); std::string command = t[0]; if (command == "spectators") { std::stringstream ss; if (client->getSpectatorCount() > 0) { ss << "Spectators:" << '\n'; for (auto it : client->getLiveCastSpectators()) { ss << static_cast<ProtocolSpectator*>(it)->getSpectatorName() << '\n'; } } else { ss << "No spectators." << '\n'; } sendChannelMessage("", ss.str().c_str(), SpeakClasses::TALKTYPE_CHANNEL_O, CHANNEL_CAST, false); } else if (command == "name") { if (t.size() == 2) { std::string newName = t[1]; if (newName == "") { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Not enough parameters."), false); return true; } if (newName.length() > 30) { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Invalid name."), false); return true; } spectatorName = newName; sendChannelMessage("", "Your new name: " + newName, SpeakClasses::TALKTYPE_CHANNEL_O, CHANNEL_CAST, false); } else { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "Not enough parameters."), false); } } } return true; } return false; }
Future<IClient::Result> ClientWS::callAsync(ConstStrA method, JSON::ConstValue params, JSON::ConstValue context) { Synchronized<FastLockR> _(lock); if (params == null) { params = jsonFactory->array(); } else if (!params->isArray()) { params = JSON::Container(jsonFactory->array()).add(params); } JSON::Builder bld(jsonFactory); natural thisid = idcounter++; JSON::Builder::CObject req = bld("id",thisid) .container() ("method",method) ("params",params); if (context != null) { req("context",context); } ConstStrA msg = jsonFactory->toString(*req); Future<Result> f; sendTextMessage(msg); waitingResults.insert(thisid,f.getPromise()); return f; }
void ProtocolSpectator::parseSpectatorSay(NetworkMessage& msg) { SpeakClasses type = (SpeakClasses)msg.getByte(); uint16_t channelId = 0; if (type == TALKTYPE_CHANNEL_Y) { channelId = msg.get<uint16_t>(); } else { return; } const std::string text = msg.getString(); if (text.length() > 255 || channelId != CHANNEL_CAST || !client) { return; } if (client) { if (client->isSpectatorMuted(spectatorId)) { sendTextMessage(TextMessage(MESSAGE_STATUS_SMALL, "You have been muted.")); return; } if (parseCoomand(text)) { return; } g_dispatcher.addTask(createTask(std::bind(&ProtocolCaster::broadcastSpectatorMessage, client, spectatorName, text))); } }
void runLimitScreen(void) { UDWORD i, id, statid; frontendMultiMessages(); // network stuff. id = widgRunScreen(psWScreen); // Run the current set of widgets // sliders if((id > IDLIMITS_ENTRIES_START) && (id< IDLIMITS_ENTRIES_END)) { statid = widgGetFromID(psWScreen,id-1)->UserData ; if(statid) { asStructLimits[0][statid].limit = (UBYTE) ((W_SLIDER*)(widgGetFromID(psWScreen,id)))->pos; } } else { // icons that are always about. switch(id) { case IDLIMITS_RETURN: // reset the sliders.. for (i = 0; i < numStructureStats ; ++i) { asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit; } // free limiter structure freeLimitSet(); //inform others sendOptions(); eventReset(); changeTitleMode(MULTIOPTION); // make some noize. if(!ingame.localOptionsReceived) { addConsoleMessage(_("Limits reset to default values"),DEFAULT_JUSTIFY, SYSTEM_MESSAGE); } else { sendTextMessage("Limits Reset To Default Values",true); } break; case IDLIMITS_OK: resetReadyStatus(false); createLimitSet(); changeTitleMode(MULTIOPTION); break; default: break; } } widgDisplayScreen(psWScreen); // show the widgets currently running }
void SendTextEdit::keyPressEvent(QKeyEvent* e) { QString msg = toPlainText(); QPlainTextEdit::keyPressEvent(e); if((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && (e->modifiers() & Qt::ShiftModifier) == 0) emit(sendTextMessage(msg)); }
//------------------------------------------------------------------------ tresult PLUGIN_API AGain::setActive (TBool state) { if (state) { sendTextMessage ("AGain::setActive (true)"); } else { sendTextMessage ("AGain::setActive (false)"); } // reset the VuMeter value fVuPPMOld = 0.f; // call our parent setActive return AudioEffect::setActive (state); }
void Spectators::addSpectator(ProtocolGame* client) { if(++id == 65536) id = 1; std::stringstream s; s << "Spectator [" << id << "]"; spectators[client] = std::make_pair(s.str(), false); sendTextMessage(MSG_EVENT_ORANGE, s.str() + " joins your stream."); }
void Spectators::removeSpectator(ProtocolGame* client) { SpectatorList::iterator it = spectators.find(client); if(it == spectators.end()) return; StringVec::iterator mit = std::find(mutes.begin(), mutes.end(), it->second.first); if(mit != mutes.end()) mutes.erase(mit); sendTextMessage(MSG_EVENT_ORANGE, it->second.first + " leaves your stream."); spectators.erase(it); }
void ClientWS::sendResponse(JSON::ConstValue id, JSON::ConstValue result, JSON::ConstValue error) { Synchronized<FastLockR> _(lock); JSON::Builder bld(jsonFactory); JSON::Builder::CObject req = bld("id",id) ("result",result) ("error",error); ConstStrA msg = jsonFactory->toString(*req); sendTextMessage(msg); }
bool recvDataCheck(NETQUEUE queue) { int i = 0; uint32_t player = queue.index; uint32_t tempBuffer[DATA_MAXDATA] = {0}; NETbeginDecode(queue, NET_DATA_CHECK); for(i = 0; i < DATA_MAXDATA; i++) { NETuint32_t(&tempBuffer[i]); } NETend(); if (player >= MAX_PLAYERS) // invalid player number. { debug(LOG_ERROR, "invalid player number (%u) detected.", player); return false; } debug(LOG_NET, "** Received NET_DATA_CHECK from player %u", player); if (NetPlay.isHost) { if (memcmp(DataHash, tempBuffer, sizeof(DataHash))) { char msg[256] = {'\0'}; for (i=0; i<DATA_MAXDATA; i++) { if (DataHash[i] != tempBuffer[i]) break; } sprintf(msg, _("%s (%u) has an incompatible mod, and has been kicked."), getPlayerName(player), player); sendTextMessage(msg, true); addConsoleMessage(msg, LEFT_JUSTIFY, NOTIFY_MESSAGE); kickPlayer(player, "your data doesn't match the host's!", ERROR_WRONGDATA); debug(LOG_WARNING, "%s (%u) has an incompatible mod. ([%d] got %x, expected %x)", getPlayerName(player), player, i, tempBuffer[i], DataHash[i]); debug(LOG_POPUP, "%s (%u), has an incompatible mod. ([%d] got %x, expected %x)", getPlayerName(player), player, i, tempBuffer[i], DataHash[i]); return false; } else { debug(LOG_NET, "DataCheck message received and verified for player %s (slot=%u)", getPlayerName(player), player); ingame.DataIntegrity[player] = true; } } return true; }
void HandleBadParam(const char *msg, const int from, const int actual) { char buf[255]; LOBBY_ERROR_TYPES KICK_TYPE = ERROR_INVALID; ssprintf(buf, "!!>Msg: %s, Actual: %d, Bad: %d", msg, actual, from); NETlogEntry(buf, SYNC_FLAG, actual); if (NetPlay.isHost) { ssprintf(buf, "Auto kicking player %s, invalid command received.", NetPlay.players[actual].name); sendTextMessage(buf, true); kickPlayer(actual, buf, KICK_TYPE); } }
void MainWindow::joinServer() { clientWidget = new TcpClientWidget(ui->connection_widget); clientWidget->setVisible(true); clientWidget->setUserName(ui->nickName_lineEdit->text()); ui->connection_widget->layout()->addWidget(clientWidget); ui->stackedWidget->setCurrentIndex(1); connect(ui->chatWidget,SIGNAL(textSent(QString)),clientWidget,SLOT(sendTextMessage(QString))); connect(clientWidget,SIGNAL(textMessage(QString)),ui->chatWidget,SLOT(textReceived(QString))); //clientWidget->connectSocket(ui->host_ip_lineEdit->text(),ui->port_lineEdit->text().toUInt()); clientWidget->connectSocket(ui->host_ip_lineEdit->text(),ui->port_lineEdit->text().toUInt()); }
void Client::on_SIgnIn_clicked() { if(ui->login->text() != "" && ui->password->text()!= "") { message = QString::number(authorization) + "|"; login = ui->login->text(); message += login + "|" + ui->password->text(); sendTextMessage(message); } else { QMessageBox::information(this, tr("Warning"), tr("Please enter login and password")); } }
void Client::on_addUser_clicked() { QString request; request += QString::number(addUser) + "|"; if(ui->newLogin->text() == "" || ui->newPassword->text() == "") { QMessageBox::information(this, tr("Warning"), tr("Please enter login and password!")); return; } else { request += ui->newLogin->text() + "|"; request += ui->newPassword->text() + "|"; } if(ui->simpleUser->isChecked()) { request += QString::number(SimpleUser); ui->simpleUser->setAutoExclusive(false); ui->simpleUser->setChecked(false); } else if(ui->advancedUser->isChecked()) { request += QString::number(AdvancedUser); ui->advancedUser->setAutoExclusive(false); ui->advancedUser->setChecked(false); } else if(ui->admin->isChecked()) { request += QString::number(Admin); ui->admin->setAutoExclusive(false); ui->admin->setChecked(false); } else { QMessageBox::information(this, tr("Warning"), tr("Please choose user rigths!")); return; } sendTextMessage(request); ui->newLogin->setText(""); ui->newPassword->setText(""); }
// Another player is broadcasting a map, recv a chunk. Returns false if not yet done. bool recvMapFileData(NETQUEUE queue) { mapDownloadProgress = NETrecvFile(queue); if (mapDownloadProgress == 100) { addConsoleMessage("MAP DOWNLOADED!",DEFAULT_JUSTIFY, SYSTEM_MESSAGE); sendTextMessage("MAP DOWNLOADED",true); //send debug(LOG_NET, "=== File has been received. ==="); // clear out the old level list. levShutDown(); levInitialise(); rebuildSearchPath(mod_multiplay, true); // MUST rebuild search path for the new maps we just got! if (!buildMapList()) { return false; } return true; } return false; }
void runLimitScreen(void) { frontendMultiMessages(); // network stuff. WidgetTriggers const &triggers = widgRunScreen(psWScreen); unsigned id = triggers.empty()? 0 : triggers.front().widget->id; // Just use first click here, since the next click could be on another menu. // sliders if((id > IDLIMITS_ENTRIES_START) && (id< IDLIMITS_ENTRIES_END)) { unsigned statid = widgGetFromID(psWScreen,id-1)->UserData; if(statid) { asStructLimits[0][statid].limit = (UBYTE) ((W_SLIDER*)(widgGetFromID(psWScreen,id)))->pos; } } else { // icons that are always about. switch(id) { case IDLIMITS_RETURN: // reset the sliders.. for (unsigned i = 0; i < numStructureStats; ++i) { asStructLimits[0][i].limit = asStructLimits[0][i].globalLimit; } // free limiter structure freeLimitSet(); //inform others if (bHosted) { sendOptions(); } eventReset(); changeTitleMode(MULTIOPTION); // make some noize. if(!ingame.localOptionsReceived) { addConsoleMessage(_("Limits reset to default values"),DEFAULT_JUSTIFY, SYSTEM_MESSAGE); } else { sendTextMessage("Limits Reset To Default Values",true); } break; case IDLIMITS_OK: resetReadyStatus(false); createLimitSet(); changeTitleMode(MULTIOPTION); break; default: break; } } widgDisplayScreen(psWScreen); // show the widgets currently running }
// **************************************************************************** // *** Main Function ********************************************************** // **************************************************************************** void main(void) { initialization(); sendTextMessage("What Hath God Wrought? Number 1"); while(1){ // sendTextMessage("What Hath God Wrought \r\n"); // int angleForMessage = getHandleAngle(); // char angleMessage[20]; // angleMessage[0]=0; // longToString(angleForMessage, angleMessage); // // concat(angleMessage, "\r \n"); // sendMessage("angle: "); // sendMessage(angleMessage); } waterPrimeTimeOut /= upstrokeInterval; leakRateTimeOut /= upstrokeInterval; //timeBetweenUpstrokes /= upstrokeInterval; // Do all of these values need to be reset each time around the loop? Or at the end of the day? 06-16-2014 int handleMovement = 0; // Either 1 or no 0 if the handle moving upward int timeOutStatus = 0; // Used to keep track of the water prime timeout int hour = 0; // Hour of day float angleCurrent = 0; // Stores the current angle of the pump handle float anglePrevious = 0; // Stores the last recoreded angle of the pump handle float angleDelta = 0; // Stores the difference between the current and previous angles float upStroke = 0; // 0 if there is no upstroke, otherwise stores the delta angle float upStrokePrime = 0; // Stores the sum of the upstrokes for calculating the prime float upStrokeExtract = 0; // Stores the sum of the upstrokes for calculating volume float volumeEvent = 0; // Stores the volume extracted float leakRatePrevious = 0; // Stores the previous Leak Rate incase if someone stats to pump before leakage can be measured //float extractionStartTime = 0; // The time of day (in seconds) when the extraction started //float extractionEndTime = 0; // The time of day (in seconds) when the extraction ended //float extractionDuration = 0; // The difference between the extraction start and end times long leakTimeCounter = 0; // Used to keep track of the leak time timeout float upStrokePrimeMeters = 0; // Stores the upstroke in meters float leakRate = 0; // Rate at which water is leaking from the rising main // float leakTime = 0; // The number of milliseconds from when the user stops pumping until there is no water (min: 0, max: 10 minutes) // long upStrokeDelayCounter = 0; // int currentHour; int currentDay; int currentHourDepthSensor; float deltaAverage; while (1) { //MAIN LOOP; repeats indefinitely //////////////////////////////////////////////////////////// // Idle Handle Monitor Loop // 2 axis of the accelerometer are constantly polled for // motion in the upward direction by comparing angles //////////////////////////////////////////////////////////// // Get the angle of the pump handle to measure against anglePrevious = getHandleAngle(); float previousAverage = 0; // Set the handle movement to 0 (handle is not moving) handleMovement = 0; // Loop until the handle starts moving float angleAccumulated=0; while (handleMovement == 0) { currentDay = getDateI2C(); if ( prevDay != currentDay){ //(prevDay != getDateI2C()){// it's a new day so send midNightMessage(); batteryFloat = batteryLevel(); midnightMessage(); } if (depthSensorInUse == 1){ // if the Depth sensor is present delayMs(1000); int currentDayDepthSensor = BcdToDec(getDateI2C()); delayMs(1000); if ((BcdToDec(getHourI2C() == 12) && (prevDayDepthSensor != currentDayDepthSensor))); midDayDepthRead(); } delayMs(upstrokeInterval); // Delay for a short time float newAngle = getHandleAngle(); float deltaAngle = abs(newAngle - anglePrevious); anglePrevious = newAngle; if (deltaAngle > 2){ // prevents floating accelerometer values when it's not actually moving angleAccumulated += deltaAngle; } // If the angle has changed, set the handleMovement flag if (angleAccumulated > 5) //05-30-14 Test for small delta's used to be angleDeltaThreshold { handleMovement = 1; } } ///////////////////////////////////////////////////////// // Priming Loop // The total amount of upstroke is recorded while the // upper water sensor is checked to determine if the // pump has been primed ///////////////////////////////////////////////////////// timeOutStatus = 0; // prepares timeoutstatus for new event // Get the angle of the pump handle to measure against anglePrevious = getHandleAngle(); upStrokePrime = 0; // gets the variable ready for a new event upStroke = 0; // gets variable ready for new event // averaging angle Code 9/17/2015 initializeQueue(anglePrevious); previousAverage = queueAverage(); // Averaging angle code while ((timeOutStatus < waterPrimeTimeOut) && !readWaterSensor()) { delayMs(upstrokeInterval); // delay a short time (10ms) // averaging angle Code 9/17/2015 pushToQueue(getHandleAngle()); //get Current angle of the pump handle deltaAverage = queueAverage() - previousAverage(); previousAverage = queueAverage(); // end averaging angle Code angleCurrent = getHandleAngle(); // Get the current angle of the pump handle angleDelta = angleCurrent - anglePrevious; // Calculate the change in angle of the pump handle //if(angleDelta > 5){ if (deltaAverage > 5){ // averaging angle code 9/17/2015 upStroke + = deltaAverage; // angle Code 9/17/2015 // upStroke += angleDelta; upStrokePrime += degToRad(upStroke); // Update the upStrokePrime timeOutStatus=0; // upstroke and current angle } else{ timeOutStatus++;} anglePrevious = angleCurrent; // Update the previous angle for the next calculation }
// //////////////////////////////////////////////////////////////////////////// // process clicks made by user. void intProcessMultiMenu(UDWORD id) { UBYTE i; //close if (id == MULTIMENU_CLOSE) { intCloseMultiMenu(); } //alliance button if(id >=MULTIMENU_ALLIANCE_BASE && id<MULTIMENU_ALLIANCE_BASE+MAX_PLAYERS) { i =(UBYTE)( id - MULTIMENU_ALLIANCE_BASE); switch(alliances[selectedPlayer][i]) { case ALLIANCE_BROKEN: requestAlliance((UBYTE)selectedPlayer,i,true,true); // request an alliance break; case ALLIANCE_INVITATION: formAlliance((UBYTE)selectedPlayer,i,true,true,true); // form an alliance break; case ALLIANCE_REQUESTED: breakAlliance((UBYTE)selectedPlayer,i,true,true); // break an alliance break; case ALLIANCE_FORMED: breakAlliance((UBYTE)selectedPlayer,i,true,true); // break an alliance break; default: break; } } //channel opens. if(id >=MULTIMENU_CHANNEL && id<MULTIMENU_CHANNEL+MAX_PLAYERS) { i = id - MULTIMENU_CHANNEL; openchannels[i] = !openchannels[i]; if(mouseDown(MOUSE_RMB) && NetPlay.isHost) // both buttons.... { char buf[250]; // Allow the host to kick the AI only in a MP game, or if they activated cheats in a skirmish game if ((NetPlay.bComms || Cheated) && (NetPlay.players[i].allocated || (NetPlay.players[i].allocated == false && NetPlay.players[i].ai != AI_OPEN))) { inputLoseFocus(); ssprintf(buf, _("The host has kicked %s from the game!"), getPlayerName((unsigned int) i)); sendTextMessage(buf, true); ssprintf(buf, _("kicked %s : %s from the game, and added them to the banned list!"), getPlayerName((unsigned int) i), NetPlay.players[i].IPtextAddress); NETlogEntry(buf, SYNC_FLAG, (unsigned int) i); kickPlayer((unsigned int) i, "you are unwanted by the host.", ERROR_KICKED); return; } } } //radar gifts if(id >= MULTIMENU_GIFT_RAD && id< MULTIMENU_GIFT_RAD +MAX_PLAYERS) { sendGift(RADAR_GIFT, id - MULTIMENU_GIFT_RAD); } // research gift if(id >= MULTIMENU_GIFT_RES && id<MULTIMENU_GIFT_RES +MAX_PLAYERS) { sendGift(RESEARCH_GIFT, id - MULTIMENU_GIFT_RES); } //droid gift if(id >= MULTIMENU_GIFT_DRO && id< MULTIMENU_GIFT_DRO +MAX_PLAYERS) { sendGift(DROID_GIFT, id - MULTIMENU_GIFT_DRO); } //power gift if(id >= MULTIMENU_GIFT_POW && id< MULTIMENU_GIFT_POW +MAX_PLAYERS) { sendGift(POWER_GIFT, id - MULTIMENU_GIFT_POW); } }
void Client::on_seeHistory_clicked() { sendTextMessage(QString::number(seeHistory) + "|" + login); }
void ClientWS::sendNotify(const PreparedNotify& preparedNotify) { sendTextMessage(preparedNotify.content); }
// //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// // MultiPlayer main game loop code. bool multiPlayerLoop(void) { UDWORD i; UBYTE joinCount; joinCount =0; for(i=0;i<MAX_PLAYERS;i++) { if(isHumanPlayer(i) && ingame.JoiningInProgress[i] ) { joinCount++; } } if(joinCount) { setWidgetsStatus(false); bDisplayMultiJoiningStatus = joinCount; // someone is still joining! say So // deselect anything selected. selDroidDeselect(selectedPlayer); if(keyPressed(KEY_ESC) )// check for cancel { bDisplayMultiJoiningStatus = 0; setWidgetsStatus(true); setPlayerHasLost(true); } } else //everyone is in the game now! { if(bDisplayMultiJoiningStatus) { bDisplayMultiJoiningStatus = 0; setWidgetsStatus(true); } if (!ingame.TimeEveryoneIsInGame) { ingame.TimeEveryoneIsInGame = gameTime; debug(LOG_NET, "I have entered the game @ %d", ingame.TimeEveryoneIsInGame ); if (!NetPlay.isHost) { debug(LOG_NET, "=== Sending hash to host ==="); sendDataCheck(); } } if (NetPlay.bComms) { sendPing(); } // Only have to do this on a true MP game if (NetPlay.isHost && !ingame.isAllPlayersDataOK && NetPlay.bComms) { if (gameTime - ingame.TimeEveryoneIsInGame > GAME_TICKS_PER_SEC * 60) { // we waited 60 secs to make sure people didn't bypass the data integrity checks int index; for (index=0; index < MAX_PLAYERS; index++) { if (ingame.DataIntegrity[index] == false && isHumanPlayer(index) && index != NET_HOST_ONLY) { char msg[256] = {'\0'}; sprintf(msg, _("Kicking player %s, because they tried to bypass data integrity check!"), getPlayerName(index)); sendTextMessage(msg, true); addConsoleMessage(msg, LEFT_JUSTIFY, NOTIFY_MESSAGE); NETlogEntry(msg, SYNC_FLAG, index); #ifndef DEBUG kickPlayer(index, "invalid data!", ERROR_INVALID); #endif debug(LOG_WARNING, "Kicking Player %s (%u), they tried to bypass data integrity check!", getPlayerName(index), index); } } ingame.isAllPlayersDataOK = true; } } } // if player has won then process the win effects... if(testPlayerHasWon()) { multiplayerWinSequence(false); } return true; }
//------------------------------------------------------------------------ tresult PLUGIN_API Plug::process (ProcessData& data) { //---1) Read inputs parameter changes----------- IParameterChanges* paramChanges = data.inputParameterChanges; if (paramChanges) { int32 numParamsChanged = paramChanges->getParameterCount (); // for each parameter which are some changes in this audio block: for (int32 i = 0; i < numParamsChanged; i++) { IParamValueQueue* paramQueue = paramChanges->getParameterData (i); if (paramQueue) { int32 offsetSamples; double value; int32 numPoints = paramQueue->getPointCount (); switch (paramQueue->getParameterId ()) { case kBypassId: if (paramQueue->getPoint (numPoints - 1, offsetSamples, value) == kResultTrue) { bBypass = (value > 0.5f); } break; } } } } //---2) Read input events------------- IEventList* eventList = data.inputEvents; if (eventList) { int32 numEvent = eventList->getEventCount (); for (int32 i = 0; i < numEvent; i++) { Event event; if (eventList->getEvent (i, event) == kResultOk) { switch (event.type) { //---------------------- case Event::kNoteOnEvent: { mLastNoteOnPitch = event.noteOn.pitch; mLastNoteOnId = event.noteOn.noteId; /*String str; str.printf (STR("noteON %d"), event.noteOff.noteId); sendTextMessage (str);*/ } break; //---------------------- case Event::kNoteOffEvent: { /* String str; str.printf (STR("noteOff %d"), event.noteOff.noteId); sendTextMessage (str); */} break; //---------------------- case Event::kNoteExpressionTextEvent: // noteOff reset the reduction if (event.noteExpressionText.typeId == kTextTypeID) { //if (mLastNoteOnId == event.noteExpressionText.noteId) { String str (STR("Text: ")); str += event.noteExpressionText.text; String tmp1; tmp1.printInt64 (mLastNoteOnId); String tmp2; tmp2.printInt64 (event.noteExpressionText.noteId); str += STR(" - id:"); str += tmp2; str += STR(" - noteOn id:"); str += tmp1; sendTextMessage (str); } } else if (event.noteExpressionText.typeId == kPhonemeTypeID) { //if (mLastNoteOnId == event.noteExpressionText.noteId) { String str (STR("Phoneme: ")); str += event.noteExpressionText.text; String tmp1; tmp1.printInt64 (mLastNoteOnId); String tmp2; tmp2.printInt64 (event.noteExpressionText.noteId); str += STR(" - id:"); str += tmp2; str += STR(" - noteOn id:"); str += tmp1; } } break; } } } } //------------------------------------- //---3) Process Audio--------------------- //------------------------------------- if (data.numOutputs == 0) { // nothing to do return kResultOk; } // no output float** out = data.outputs[0].channelBuffers32; for (int32 i = 0; i < data.outputs[0].numChannels; i++) { memset (out[i], 0, data.numSamples * sizeof (float)); } data.outputs[0].silenceFlags = 0x7fff; return kResultOk; }
bool YOGServerAdministrator::executeAdministrativeCommand(const std::string& message, boost::shared_ptr<YOGServerPlayer> player, bool moderator) { std::vector<std::string> tokens; std::string token; bool isQuotes=false; for(unsigned int i=0; i<message.size(); ++i) { if(message[i]==' ' && !isQuotes) { if(!token.empty()) { tokens.push_back(token); token.clear(); } } else if(message[i]=='"' && isQuotes) { isQuotes=false; } else if(message[i]=='"' && !isQuotes) { isQuotes=true; } else { token+=message[i]; } } if(!token.empty()) { tokens.push_back(token); token.clear(); } if(tokens.size() == 0) { return false; } if(tokens[0] == ".help") { if(moderator) sendTextMessage("The current list of YOG Administrative Commands available for moderators are: ", player); else sendTextMessage("The current list of YOG Administrative Commands are: ", player); for(unsigned int i=0; i<commands.size(); ++i) { if(!moderator || commands[i]->allowedForModerator()) { sendTextMessage(commands[i]->getHelpMessage(), player); } } sendTextMessage(".help Shows this help message", player); } else { for(unsigned int i=0; i<commands.size(); ++i) { if(!moderator || commands[i]->allowedForModerator()) { if(tokens[0] == commands[i]->getCommandName()) { if(!commands[i]->doesMatch(tokens)) { sendTextMessage(commands[i]->getHelpMessage(), player); } else { commands[i]->execute(server, this, tokens, player); } } } } } return false; }