ADD: Message container and Join Message
This commit is contained in:
88
include/WHISPER/Messages/Message.hpp
Normal file
88
include/WHISPER/Messages/Message.hpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
#include "google/protobuf/any.pb.h"
|
||||
#include "google/protobuf/message.h"
|
||||
#include <WHISPER/Messages/Protos/message.pb.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <loguru.hpp>
|
||||
|
||||
|
||||
namespace WHISPER {
|
||||
|
||||
enum MsgType : int32_t
|
||||
{
|
||||
/// message to shutdown all participants
|
||||
SHUTDOWN = 0,
|
||||
/// on participant is joined
|
||||
JOIN=1,
|
||||
/// participant is leaving
|
||||
LEAVE,
|
||||
/// owntrack informaton
|
||||
OWN_TRACK,
|
||||
/// raw track message
|
||||
RAW_TRACK,
|
||||
/// simple data
|
||||
SIMPLE
|
||||
}; // enum class EventType
|
||||
|
||||
enum SourceType : int32_t
|
||||
{
|
||||
SIMCOMTROLER,
|
||||
///
|
||||
SHIP,
|
||||
///
|
||||
SENSOR,
|
||||
///
|
||||
EFEKTOR,
|
||||
///
|
||||
GATEWAY,
|
||||
///
|
||||
|
||||
|
||||
}; // enum class EventType
|
||||
|
||||
|
||||
|
||||
|
||||
class Message{
|
||||
private:
|
||||
std::string payloadString_;
|
||||
std::shared_ptr<google::protobuf::Any> payload_;
|
||||
|
||||
public:
|
||||
Message()=default;
|
||||
|
||||
Message(std::int32_t deviceId, std::uint32_t topic, MsgType Type,SourceType src);
|
||||
Message(std::string msg);
|
||||
|
||||
std::string getPayloadString();
|
||||
|
||||
std::uint32_t topic_;
|
||||
std::int32_t msgType_;
|
||||
std::int32_t sourceType_;
|
||||
std::int32_t deviceId_;
|
||||
|
||||
void addPayLoad(std::shared_ptr<google::protobuf::Any> any);
|
||||
void addPayLoad(std::string any);
|
||||
|
||||
std::string serialize();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
messages::header::Message msg;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user