snapcast/message/commandMsg.h
(no author) 29bcbe43b0 requests are enum
git-svn-id: svn://elaine/murooma/trunk@305 d8a302eb-03bc-478d-80e4-98257eca68ef
2014-09-28 08:42:56 +00:00

52 lines
851 B
C++

#ifndef COMMAND_MSG_H
#define COMMAND_MSG_H
#include "message.h"
#include <string>
class CommandMsg : public BaseMessage
{
public:
CommandMsg() : BaseMessage(message_type::commandmsg), command("")
{
}
CommandMsg(const std::string& _command) : BaseMessage(message_type::commandmsg), command(_command)
{
}
virtual ~CommandMsg()
{
}
virtual void read(std::istream& stream)
{
int16_t size;
stream.read(reinterpret_cast<char *>(&size), sizeof(int16_t));
command.resize(size);
stream.read(&command[0], size);
}
virtual uint32_t getSize()
{
return sizeof(int16_t) + command.size();
}
std::string command;
protected:
virtual void doserialize(std::ostream& stream)
{
int16_t size(command.size());
stream.write(reinterpret_cast<char *>(&size), sizeof(int16_t));
stream.write(command.c_str(), size);
}
};
#endif