Example #1
0
//from CChannelHandler
void CClimateClientProfile::bufferReceived(const iviLink::Channel::tChannelId channel, iviLink::CBuffer const& buffer)
{
   LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
   if (mChannelID != channel)
   {
      LOG4CPLUS_INFO(msLogger, "mChannelID != channel");
      return;
   }
   else
   {
      LOG4CPLUS_INFO(msLogger, "mChannelID == channel");
   }

   Json::Value value; // will contain the root value after parsing.
   Json::Reader reader;

   bool parsingSuccessful = reader.parse((char*)buffer.getBuffer(), value);
   if (!parsingSuccessful)
   {
     LOG4CPLUS_INFO(msLogger, "Failed to parse income message");
   }
   else
   {
      LOG4CPLUS_INFO(msLogger, "Incoming notification");
      mpAppCallbacks->incomingNotification(value);
   }
}
Example #2
0
void ReceiverProfile<T,I>::onBufferReceived(const iviLink::Channel::tChannelId channel, iviLink::CBuffer const& buffer)
{
    LOG4CPLUS_TRACE_METHOD((logger<T,I>()), __PRETTY_FUNCTION__ );

    if (mChannelID != channel)
    {
        LOG4CPLUS_INFO((logger<T,I>()), "mChannelID != channel");
        return;
    }
    else
    {
        LOG4CPLUS_INFO((logger<T,I>()), "mChannelID == channel");
    }

    typename I::state_t st;
    if( st.deserialize(std::string((char*)buffer.getBuffer()) ) )
    {
        //LOG4CPLUS_INFO( msLogger, "seat receiver profile: recive\n" + st.DebugString() );
        receive( st );
    }
    else
        LOG4CPLUS_ERROR( (logger<T,I>()), "Failed to deserialize state from buffer" );
}
void CMediaControlServerProfile::onBufferReceived(const iviLink::Channel::tChannelId channel, iviLink::CBuffer const& buffer) {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__);
    if (mChannelID != channel)
    {
        LOG4CPLUS_INFO(msLogger, "mChannelID != channel_id");
        return;
    }
    else
    {
        LOG4CPLUS_INFO(msLogger, "mChannelID == channel_id");
    }

    UInt8 *incomingData = buffer.getBuffer();
    int read_size = buffer.getSize();

    LOG4CPLUS_INFO(msLogger, "Procedure ID = " + convertIntegerToString(incomingData[0]));

    if(incomingData[0] == STOP)
    {
        LOG4CPLUS_INFO(msLogger, "case STOP");
        mpAppCallbacks->onServerStop();
        mpServControl->sendCommand(mpServControl->mStop);

    }
    else if(incomingData[0] == SERVERSTOP)
    {
        LOG4CPLUS_INFO(msLogger, "case SERVERSTOP");
        serverStop();
    }
    else if(incomingData[0] == PAUSE)
    {
        LOG4CPLUS_INFO(msLogger, "case PAUSE");
        mpAppCallbacks->onServerPause();
        mpServControl->sendCommand(mpServControl->mPause);
    }
    else if(incomingData[0] == RESUME)
    {
        LOG4CPLUS_INFO(msLogger, "case RESUME");
        resume();
    }
    else if(incomingData[0] == SYNC)
    {
        LOG4CPLUS_INFO(msLogger, "case SYNC");
        mpAppCallbacks->onServerSync();
    }
    else if(incomingData[0] == UNSYNC)
    {
        LOG4CPLUS_INFO(msLogger, "case UNSYNC");
        mpAppCallbacks->onServerUnsync();
    }
    else if(incomingData[0] == TOGGLE)
    {
        LOG4CPLUS_INFO(msLogger, "case TOGGLE");
        mpAppCallbacks->onServerToggle();
    }
    else if(incomingData[0] == PLAY)
    {
        LOG4CPLUS_INFO(msLogger, "case PLAY");
        std::string message((char*)(incomingData + 1), read_size - 1);
        LOG4CPLUS_INFO(msLogger, "message  = " + message);
        vector<string> parse_result;
        split(message, ";", parse_result);
        if (parse_result.size() == 3)
        {
            LOG4CPLUS_INFO(msLogger, parse_result[0]);
            LOG4CPLUS_INFO(msLogger, parse_result[1]);
            LOG4CPLUS_INFO(msLogger, parse_result[2]);
            LOG4CPLUS_INFO(msLogger, "get message:" + parse_result[0] + " ; " + parse_result[1] + " ; " + parse_result[2]);
            play(parse_result[0], parse_result[1], parse_result[2]);
        }
        else
        {
            LOG4CPLUS_INFO(msLogger, "cannot parse message");
        }

    }
    else
    {
        LOG4CPLUS_INFO(msLogger, "unknown procedure ID");
    }

}
Example #4
0
//from CChannelHandler
void CSeatHUProfile::bufferReceived(const iviLink::Channel::tChannelId channel, iviLink::CBuffer const& buffer)
{
   LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
   if (mChannelID != channel)
   {
      LOG4CPLUS_INFO(msLogger, "mChannelID != channel_id");
      return;
   }
   else
   {
      LOG4CPLUS_INFO(msLogger, "mChannelID == channel_id");
   }

   bool res = true;
   UInt16 tmp;
   res = res && buffer.read(tmp);
   if (!res)
   {
      LOG4CPLUS_WARN(msLogger, "Unable to read request type from buffer");
      return;
   }
   EReqType reqType = static_cast<EReqType>(tmp);

   switch(reqType)
   {
   case REQ_TYPE_INIT:
      {
         LOG4CPLUS_INFO(msLogger, "case REQ_TYPE_INIT");
         mpAppCallbacks->onInitRequest();
      }
      break;
   case REQ_TYPE_TAB:
      {
         LOG4CPLUS_INFO(msLogger, "case REQ_TYPE_TAB");
         res = res && buffer.read(tmp);
         if (res)
            mpAppCallbacks->onTabRequest(static_cast<EPersonEvent>(tmp));

      }
      break;
   case REQ_TYPE_HEATER:
      {
         LOG4CPLUS_INFO(msLogger, "case REQ_TYPE_HEATER");
         res = res && buffer.read(tmp);
         if (res)
            mpAppCallbacks->onHeaterRequest(static_cast<EPersonEvent>(tmp));
      }
      break;
   case REQ_TYPE_MOVE:
      {
         LOG4CPLUS_INFO(msLogger, "case REQ_TYPE_MOVE");
         res = res && buffer.read(tmp);
         if (res)
            mpAppCallbacks->onMoveRequest(static_cast<EMoveEvent>(tmp));
      }
      break;
   default:
      {
         LOG4CPLUS_WARN(msLogger, "Unknown request type");
         return;
      }
      break;
   }

   if (!res)
   {
      LOG4CPLUS_WARN(msLogger, "Unable to read event from buffer");
      return;
   }
}