#ifndef TCPSERVER_SERVER_H
#define TCPSERVER_SERVER_H

#include <QTcpServer>
#include <vector>

#include "server.h"

class TcpServer : public Server
{
	Q_OBJECT

	QTcpServer server;

public:
	TcpServer(QObject* parent = nullptr);
	virtual  bool launch(const QHostAddress &address = QHostAddress::Any, quint16 port = 0) override;
	virtual void sendJson(const QJsonObject& json) override;
	quint16 getServerPort() const { return server.serverPort(); }
	bool isListening() const { return server.isListening(); }

signals:
	void sigRequestSave();

private slots:
	void incomingConnection();
	void socketReadyRead();

protected:
	virtual void processIncomeingJson(const QByteArray& jsonbytes) override;

private:
	void processComand(const QByteArray& command, Client& client);
};

#endif // TCPSERVER_SERVER_H
