Ignore:
Timestamp:
02/14/13 16:02:05 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 3 'hg:/home/ivaradi/xplane/hg/xplra' '/'>, 'public')
Message:

Added basic support for showing a message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/plugin/src/xplra/ServerThread.cc

    r36 r38  
    3939#include "GetMultiDataRefRequest.h"
    4040#include "SetMultiDataRefRequest.h"
     41#include "MessageRequest.h"
    4142
    4243#include <hu/varadiistvan/xplcommon/Util.h>
     
    152153        } else if (command==Protocol::COMMAND_GET_VERSIONS) {
    153154            if (!handleGetVersions()) break;
     155        } else if (command==Protocol::COMMAND_SHOW_MESSAGE) {
     156            if (!handleShowMessage()) break;
    154157        } else {
    155158            stream.writeU8(Protocol::RESULT_INVALID_COMMAND);
     
    400403    stream.writeS32(xplmVersion);
    401404    stream.writeS32(Protocol::version);
     405
     406    return true;
     407}
     408
     409//------------------------------------------------------------------------------
     410
     411bool ServerThread::handleShowMessage()
     412{
     413    string message = stream.readString();
     414    float duration = stream.readFloat();
     415    if (!stream) return false;
     416
     417    if (duration>Protocol::MAX_MESSAGE_DURATION) {
     418        stream.writeU8(Protocol::RESULT_INVALID_DURATION);
     419    } else {
     420        MessageRequest request(listenThread.getMessageWindow(), message, duration);
     421        if (!requestQueue.execute(&request)) return false;
     422
     423        stream.writeU8(Protocol::RESULT_OK);
     424    }
    402425
    403426    return true;
Note: See TracChangeset for help on using the changeset viewer.