Ignore:
Timestamp:
02/14/13 18:21:47 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the client support for the new commands and updated the basic test programs with tests showing messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/client/c/hu/varadiistvan/xplra/XPlane.cc

    r36 r40  
    7373//------------------------------------------------------------------------------
    7474
    75 void XPlane::checkResult(uint8_t result) throw(ProtocolException)
     75void XPlane::checkResult(uint8_t result, bool hasParameter, long parameter)
     76    throw(ProtocolException)
    7677{
    7778    switch(result) {
     
    7980        return;
    8081      case Protocol::RESULT_INVALID_COMMAND:
    81         throw ProtocolException(ProtocolException::INVALID_COMMAND);
     82        throw ProtocolException(ProtocolException::INVALID_COMMAND,
     83                                hasParameter, parameter);
    8284      case Protocol::RESULT_UNKNOWN_DATAREF:
    83         throw ProtocolException(ProtocolException::UNKNOWN_DATAREF);
     85        throw ProtocolException(ProtocolException::UNKNOWN_DATAREF,
     86                                hasParameter, parameter);
    8487      case Protocol::RESULT_INVALID_TYPE:
    85         throw ProtocolException(ProtocolException::INVALID_TYPE);
     88        throw ProtocolException(ProtocolException::INVALID_TYPE,
     89                                hasParameter, parameter);
    8690      case Protocol::RESULT_INVALID_LENGTH:
    87         throw ProtocolException(ProtocolException::INVALID_LENGTH);
     91        throw ProtocolException(ProtocolException::INVALID_LENGTH,
     92                                hasParameter, parameter);
    8893      case Protocol::RESULT_INVALID_OFFSET:
    89         throw ProtocolException(ProtocolException::INVALID_OFFSET);
     94        throw ProtocolException(ProtocolException::INVALID_OFFSET,
     95                                hasParameter, parameter);
    9096      case Protocol::RESULT_INVALID_COUNT:
    91         throw ProtocolException(ProtocolException::INVALID_COUNT);
     97        throw ProtocolException(ProtocolException::INVALID_COUNT,
     98                                hasParameter, parameter);
    9299      case Protocol::RESULT_INVALID_ID:
    93         throw ProtocolException(ProtocolException::INVALID_ID);
     100        throw ProtocolException(ProtocolException::INVALID_ID,
     101                                hasParameter, parameter);
     102      case Protocol::RESULT_INVALID_DURATION:
     103        throw ProtocolException(ProtocolException::INVALID_DURATION,
     104                                hasParameter, parameter);
    94105      case Protocol::RESULT_OTHER_ERROR:
    95106      default:
    96         throw ProtocolException(ProtocolException::OTHER);
     107        throw ProtocolException(ProtocolException::OTHER,
     108                                hasParameter, parameter);
    97109    }
    98110}
     
    100112//------------------------------------------------------------------------------
    101113
    102 void XPlane::checkResult() throw(ProtocolException, IOException)
     114void XPlane::checkResult(bool multi) throw(ProtocolException, IOException)
    103115{
    104116    uint8_t result = stream->readU8();
    105     checkStream();
    106     checkResult(result);
     117    bool hasParameter = false;
     118    long parameter = 0;
     119    if (multi) {
     120        if (result==Protocol::RESULT_UNKNOWN_DATAREF) {
     121            parameter = stream->readU32();
     122            hasParameter = true;
     123        }
     124    }
     125    checkStream();
     126    checkResult(result, hasParameter, parameter);
    107127}
    108128
     
    205225
    206226    checkStream();
     227}
     228
     229//------------------------------------------------------------------------------
     230
     231void XPlane::reloadPlugins() throw(Exception)
     232{
     233    stream->writeU8(Protocol::COMMAND_RELOAD_PLUGINS);
     234    stream->flush();
     235    checkResult();
    207236}
    208237
     
    457486    }
    458487}
     488
     489//------------------------------------------------------------------------------
     490
     491void XPlane::showMessage(const char* message, float duration) throw(Exception)
     492{
     493    stream->writeU8(Protocol::COMMAND_SHOW_MESSAGE);
     494    stream->writeString(message);
     495    stream->writeFloat(duration);
     496    stream->flush();
     497    checkResult();
     498}
     499
    459500//------------------------------------------------------------------------------
    460501
Note: See TracChangeset for help on using the changeset viewer.