mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-26 12:58:47 +02:00
refactoring
git-svn-id: svn://elaine/murooma/trunk@328 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
611b2a6c9f
commit
c40bfda64c
35 changed files with 192 additions and 178 deletions
55
message/command.h
Normal file
55
message/command.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifndef COMMAND_MSG_H
|
||||
#define COMMAND_MSG_H
|
||||
|
||||
#include "message.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace msg
|
||||
{
|
||||
|
||||
class Command : public BaseMessage
|
||||
{
|
||||
public:
|
||||
Command() : BaseMessage(message_type::kCommand), command("")
|
||||
{
|
||||
}
|
||||
|
||||
Command(const std::string& _command) : BaseMessage(message_type::kCommand), command(_command)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Command()
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue