revert FIX: fixed message class to that only one any message can be stored; deleted track class
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
#include "WHISPER/Messages/Message.hpp"
|
|
#include "WHISPER/Messages/Protos/raw_track.pb.h"
|
|
#include <WHISPER/Messages/Track.hpp>
|
|
#include <memory>
|
|
|
|
|
|
|
|
|
|
namespace WHISPER {
|
|
|
|
RawTrack::RawTrack(std::string receivedMessage){
|
|
msg = messages::header::Message();
|
|
try {
|
|
msg.ParseFromString(receivedMessage);
|
|
topic_ = msg.topic();
|
|
sourceType_ = msg.sourcetype();
|
|
msgType_ = msg.msgtype();
|
|
|
|
trackMessage = messages::raw_track::RawTrack();
|
|
|
|
if ( msg.payload_size()) {
|
|
if (msg.payload().begin()->Is<messages::raw_track::RawTrack>()) {
|
|
msg.payload().begin()->UnpackTo(&trackMessage);
|
|
}
|
|
}
|
|
|
|
|
|
trackNo = trackMessage.trackno();
|
|
|
|
|
|
|
|
} catch (const std::exception& e) {
|
|
LOG_S(ERROR)<<e.what();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
RawTrack::RawTrack(std::uint32_t deviceID,WHISPER::MsgTopics topic, SourceType src,std::uint32_t trackNo):
|
|
Message(deviceID,WHISPER::MsgTopics::TRACK,WHISPER::RAW_TRACK,src),trackNo(trackNo)
|
|
{
|
|
|
|
trackMessage = messages::raw_track::RawTrack();
|
|
trackMessage.set_trackno(trackNo);
|
|
|
|
auto payloadMessage = std::make_shared<google::protobuf::Any>();
|
|
payloadMessage->PackFrom(trackMessage);
|
|
addPayLoad(payloadMessage);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} |