mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-12 00:26:41 +02:00
removed Ack & String message
This commit is contained in:
parent
4218bedd01
commit
8816826bcd
4 changed files with 3 additions and 149 deletions
|
@ -31,7 +31,6 @@
|
|||
#include "message/serverSettings.h"
|
||||
#include "message/time.h"
|
||||
#include "message/request.h"
|
||||
#include "message/ack.h"
|
||||
#include "message/hello.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2016 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#ifndef ACK_MSG_H
|
||||
#define ACK_MSG_H
|
||||
|
||||
#include "message.h"
|
||||
|
||||
namespace msg
|
||||
{
|
||||
|
||||
class Ack : public BaseMessage
|
||||
{
|
||||
public:
|
||||
Ack() : BaseMessage(message_type::kAck), message("")
|
||||
{
|
||||
}
|
||||
|
||||
Ack(const std::string& _message) : BaseMessage(message_type::kAck), message(_message)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Ack()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void read(std::istream& stream)
|
||||
{
|
||||
int16_t size;
|
||||
stream.read(reinterpret_cast<char *>(&size), sizeof(int16_t));
|
||||
message.resize(size);
|
||||
stream.read(&message[0], size);
|
||||
}
|
||||
|
||||
virtual uint32_t getSize() const
|
||||
{
|
||||
return sizeof(int16_t) + message.size();
|
||||
}
|
||||
|
||||
std::string message;
|
||||
|
||||
protected:
|
||||
virtual void doserialize(std::ostream& stream) const
|
||||
{
|
||||
int16_t size(message.size());
|
||||
stream.write(reinterpret_cast<const char *>(&size), sizeof(int16_t));
|
||||
stream.write(message.c_str(), size);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -55,11 +55,11 @@ enum message_type
|
|||
kServerSettings = 4,
|
||||
kTime = 5,
|
||||
kRequest = 6,
|
||||
kAck = 7,
|
||||
// kAck = 7,
|
||||
// kCommand = 8,
|
||||
kHello = 9,
|
||||
kMap = 10,
|
||||
kString = 11
|
||||
kMap = 10
|
||||
// kString = 11
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/***
|
||||
This file is part of snapcast
|
||||
Copyright (C) 2014-2016 Johannes Pohl
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#ifndef STRING_MESSAGE_H
|
||||
#define STRING_MESSAGE_H
|
||||
|
||||
#include "message.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace msg
|
||||
{
|
||||
|
||||
class StringMessage : public BaseMessage
|
||||
{
|
||||
public:
|
||||
StringMessage(message_type msgType) : BaseMessage(msgType), str("")
|
||||
{
|
||||
}
|
||||
|
||||
StringMessage(message_type msgType, const std::string& _str) : BaseMessage(msgType), str(_str)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~StringMessage()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void read(std::istream& stream)
|
||||
{
|
||||
int16_t size;
|
||||
stream.read(reinterpret_cast<char *>(&size), sizeof(int16_t));
|
||||
str.resize(size);
|
||||
stream.read(&str[0], size);
|
||||
}
|
||||
|
||||
virtual uint32_t getSize() const
|
||||
{
|
||||
return sizeof(int16_t) + str.size();
|
||||
}
|
||||
|
||||
std::string str;
|
||||
|
||||
protected:
|
||||
virtual void doserialize(std::ostream& stream) const
|
||||
{
|
||||
int16_t size(str.size());
|
||||
stream.write(reinterpret_cast<const char *>(&size), sizeof(int16_t));
|
||||
stream.write(str.c_str(), size);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue